Category: Matlab
Category Archives: Matlab
Averaging rotation matrices and calculating the variability
Hi
I have multiple rotation matrices in the form of cell aray (attached).
I would like to calculate an average or a mean matrix and variability around the mean (standard deviation)
So far I have tried converting the rotation matrices to quaternions and using the meanrot to calculate the quaternion mean. But I do not know how to calculate the variability (STD or variance).
Reading around this, one approach may be to calculate the diffrence between the quaternion mean and each quaternion and porceed (not sure how)
The other way is to use the vector for the mean and the vectors for each rotation matrix; then calculate the diffrence between mean vector and each vector.
I am not sure which is mathematically correct and also how to do that.
ThanksHi
I have multiple rotation matrices in the form of cell aray (attached).
I would like to calculate an average or a mean matrix and variability around the mean (standard deviation)
So far I have tried converting the rotation matrices to quaternions and using the meanrot to calculate the quaternion mean. But I do not know how to calculate the variability (STD or variance).
Reading around this, one approach may be to calculate the diffrence between the quaternion mean and each quaternion and porceed (not sure how)
The other way is to use the vector for the mean and the vectors for each rotation matrix; then calculate the diffrence between mean vector and each vector.
I am not sure which is mathematically correct and also how to do that.
Thanks Hi
I have multiple rotation matrices in the form of cell aray (attached).
I would like to calculate an average or a mean matrix and variability around the mean (standard deviation)
So far I have tried converting the rotation matrices to quaternions and using the meanrot to calculate the quaternion mean. But I do not know how to calculate the variability (STD or variance).
Reading around this, one approach may be to calculate the diffrence between the quaternion mean and each quaternion and porceed (not sure how)
The other way is to use the vector for the mean and the vectors for each rotation matrix; then calculate the diffrence between mean vector and each vector.
I am not sure which is mathematically correct and also how to do that.
Thanks mean rotation, rotation matrix, averaging rotations MATLAB Answers — New Questions
Lead Concatenation in ECG Classification Using CWT: Required or Optional?
Dear Matlab Community,
I am currently working on a classification task with ECG recordings stored in a CSV file with dimensions of (5001, 12). The first row contains headers, and each column represents a lead of the ECG, totaling 12 leads. These recordings were made over a duration of 10 seconds at a sampling frequency of 500 Hz. Therefore, each lead comprises a sequence of 5000 values. The unit of measurement is 0.01 mV, adhering to the Philips standard recording system.
My specific question pertains to the methodology of feature extraction for classification purposes using the Continuous Wavelet Transform (CWT). Should I proceed by creating a scalogram for each lead independently and then concatenating them, or should I generate 12 scalograms from each ECG and consider them as belonging to the same class?
Put differently, is each lead’s scalogram regarded as a class instance, or is it pivotal to concatenate the 12 leads to accurately represent an ECG? Your insights and guidance on this matter would be greatly appreciated.
Sincerely,Dear Matlab Community,
I am currently working on a classification task with ECG recordings stored in a CSV file with dimensions of (5001, 12). The first row contains headers, and each column represents a lead of the ECG, totaling 12 leads. These recordings were made over a duration of 10 seconds at a sampling frequency of 500 Hz. Therefore, each lead comprises a sequence of 5000 values. The unit of measurement is 0.01 mV, adhering to the Philips standard recording system.
My specific question pertains to the methodology of feature extraction for classification purposes using the Continuous Wavelet Transform (CWT). Should I proceed by creating a scalogram for each lead independently and then concatenating them, or should I generate 12 scalograms from each ECG and consider them as belonging to the same class?
Put differently, is each lead’s scalogram regarded as a class instance, or is it pivotal to concatenate the 12 leads to accurately represent an ECG? Your insights and guidance on this matter would be greatly appreciated.
Sincerely, Dear Matlab Community,
I am currently working on a classification task with ECG recordings stored in a CSV file with dimensions of (5001, 12). The first row contains headers, and each column represents a lead of the ECG, totaling 12 leads. These recordings were made over a duration of 10 seconds at a sampling frequency of 500 Hz. Therefore, each lead comprises a sequence of 5000 values. The unit of measurement is 0.01 mV, adhering to the Philips standard recording system.
My specific question pertains to the methodology of feature extraction for classification purposes using the Continuous Wavelet Transform (CWT). Should I proceed by creating a scalogram for each lead independently and then concatenating them, or should I generate 12 scalograms from each ECG and consider them as belonging to the same class?
Put differently, is each lead’s scalogram regarded as a class instance, or is it pivotal to concatenate the 12 leads to accurately represent an ECG? Your insights and guidance on this matter would be greatly appreciated.
Sincerely, ecg, classification, feature extraction, continuous wavelet transform (cwt), scalogram, lead concatenation, signal processing MATLAB Answers — New Questions
how to get variable of function in for loop
Hello, someone please help me.
I created a polynomial function f(x,y) using two variables. I varied the values of both variables to get the maximum f(x,y) using for loop and i got it. But, i dont know how to get or display the values of the x and y that made it. can you tell me the syntax to get them? thanks!!
x = 1:20;
y = 1:13;
f = [];
for i = 1:length(x), j = 1:length(j);
f(i,j) = x(i).^2 – x(i) -2*y(j).^2 + y(j) -25;
end
fmax = max(max(f));
display(fmax)Hello, someone please help me.
I created a polynomial function f(x,y) using two variables. I varied the values of both variables to get the maximum f(x,y) using for loop and i got it. But, i dont know how to get or display the values of the x and y that made it. can you tell me the syntax to get them? thanks!!
x = 1:20;
y = 1:13;
f = [];
for i = 1:length(x), j = 1:length(j);
f(i,j) = x(i).^2 – x(i) -2*y(j).^2 + y(j) -25;
end
fmax = max(max(f));
display(fmax) Hello, someone please help me.
I created a polynomial function f(x,y) using two variables. I varied the values of both variables to get the maximum f(x,y) using for loop and i got it. But, i dont know how to get or display the values of the x and y that made it. can you tell me the syntax to get them? thanks!!
x = 1:20;
y = 1:13;
f = [];
for i = 1:length(x), j = 1:length(j);
f(i,j) = x(i).^2 – x(i) -2*y(j).^2 + y(j) -25;
end
fmax = max(max(f));
display(fmax) for loop, polynomial, variables, display MATLAB Answers — New Questions
Windows updates…Grrr!!!
Does Windows not see Matlab when checking to see if it can do an auto-restart to install updates? I read somewhere that Windows makes sure the computer is not busy before automatically restarting, but alas I came in this morning to find my overnight simulation had been aborted due to Windows installing updates!
:'(Does Windows not see Matlab when checking to see if it can do an auto-restart to install updates? I read somewhere that Windows makes sure the computer is not busy before automatically restarting, but alas I came in this morning to find my overnight simulation had been aborted due to Windows installing updates!
:'( Does Windows not see Matlab when checking to see if it can do an auto-restart to install updates? I read somewhere that Windows makes sure the computer is not busy before automatically restarting, but alas I came in this morning to find my overnight simulation had been aborted due to Windows installing updates!
:'( windows sucks! MATLAB Answers — New Questions
finding indexed max values of a matrix using logical array
Hi. Note I have a hard-coded example for this question below you can run to see what I am referring in the question.
To illustrate the problem, I have an m x n matrix G of values. Each row represents a time series of a given repeated measure. I want to get the max values along each row of G and find the (i,j) indexes of the max values of G. Then I want to find the exact time point for where in the time series the max value of G lie for each corresponding row.
My approach was to first make the time series S a repeated matix of the same row values. Then I made a logical mask M = (G == max(G, [],2)). The occurrences of logical ones do correspond to where the max values of G lie, as expected. However when I used the the logical mask M in S to get the time points for the max values of each row using S(M), I get nonsense. I am not sure what I am not understanding or doing wrong.
For instance. The first row max of G is 3 and at index =3 in the time series. Using the S(M) scheme should give "202" but doesn’t. The values for the other rows are all off as well.
Any help with this would be greatly appreciated.
_______________________________________________
UPDATE:
I realized that the scheme is technically working with the problem the values for the sequential rows is not preserved. When I type:
[i,j] = find(G == max(G, [],2)), the row order is weirdly randomized (see code section below of the order of the i values). Does any one know why this would happen? I would need to preserve the sequential order of the row values from 1:9.
S = repmat((200:202), [9,1]); % repeated matrix of consecutive indices
G = [2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2]; % matrix of random values
M = (G == max(G, [],2)) % find logical mask of max values along the rows
S(M)
[i,j] = find(G == max(G, [],2))Hi. Note I have a hard-coded example for this question below you can run to see what I am referring in the question.
To illustrate the problem, I have an m x n matrix G of values. Each row represents a time series of a given repeated measure. I want to get the max values along each row of G and find the (i,j) indexes of the max values of G. Then I want to find the exact time point for where in the time series the max value of G lie for each corresponding row.
My approach was to first make the time series S a repeated matix of the same row values. Then I made a logical mask M = (G == max(G, [],2)). The occurrences of logical ones do correspond to where the max values of G lie, as expected. However when I used the the logical mask M in S to get the time points for the max values of each row using S(M), I get nonsense. I am not sure what I am not understanding or doing wrong.
For instance. The first row max of G is 3 and at index =3 in the time series. Using the S(M) scheme should give "202" but doesn’t. The values for the other rows are all off as well.
Any help with this would be greatly appreciated.
_______________________________________________
UPDATE:
I realized that the scheme is technically working with the problem the values for the sequential rows is not preserved. When I type:
[i,j] = find(G == max(G, [],2)), the row order is weirdly randomized (see code section below of the order of the i values). Does any one know why this would happen? I would need to preserve the sequential order of the row values from 1:9.
S = repmat((200:202), [9,1]); % repeated matrix of consecutive indices
G = [2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2]; % matrix of random values
M = (G == max(G, [],2)) % find logical mask of max values along the rows
S(M)
[i,j] = find(G == max(G, [],2)) Hi. Note I have a hard-coded example for this question below you can run to see what I am referring in the question.
To illustrate the problem, I have an m x n matrix G of values. Each row represents a time series of a given repeated measure. I want to get the max values along each row of G and find the (i,j) indexes of the max values of G. Then I want to find the exact time point for where in the time series the max value of G lie for each corresponding row.
My approach was to first make the time series S a repeated matix of the same row values. Then I made a logical mask M = (G == max(G, [],2)). The occurrences of logical ones do correspond to where the max values of G lie, as expected. However when I used the the logical mask M in S to get the time points for the max values of each row using S(M), I get nonsense. I am not sure what I am not understanding or doing wrong.
For instance. The first row max of G is 3 and at index =3 in the time series. Using the S(M) scheme should give "202" but doesn’t. The values for the other rows are all off as well.
Any help with this would be greatly appreciated.
_______________________________________________
UPDATE:
I realized that the scheme is technically working with the problem the values for the sequential rows is not preserved. When I type:
[i,j] = find(G == max(G, [],2)), the row order is weirdly randomized (see code section below of the order of the i values). Does any one know why this would happen? I would need to preserve the sequential order of the row values from 1:9.
S = repmat((200:202), [9,1]); % repeated matrix of consecutive indices
G = [2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2
2 1 3
4 8 12
3 4 2]; % matrix of random values
M = (G == max(G, [],2)) % find logical mask of max values along the rows
S(M)
[i,j] = find(G == max(G, [],2)) indexing, logical arrays MATLAB Answers — New Questions
Each time maximum number of valid configs changes depending on the pick up point
Hello,
I am trying to generate some valid pick up configurations for a given orientation ( I have 17 different orientations to test) around some points in space with UR5e. I count them as well so that I know the exact number of valid pick up configurations around each point. The thing is, sometimes when I run the simulation for some points, it counts less or more then it did before. So let’s say the result of the first execution for the point A was 16 valid pick up configs around that point, the second time it can be 13 for example instead of 16. Why is this happening ? Should I modify the solver parameters of gik to overcome this ? Because if sometimes it looks like the UR5 can’t reach certain poses but other times it can so it’s not really viable.
Hello,
I am trying to generate valid pick-up configurations for a given orientation with a UR5e robot. I have 17 different orientations to test around specific points in space. For each point, I count the number of valid pick-up configurations to determine the exact number of feasible configurations.
However, I have encountered an inconsistency: the number of valid configurations varies between simulation runs. For instance, for a given point A, the first execution might yield 16 valid configurations, while the second might yield only 13.
Why is this inconsistency happening? Should I modify the solver parameters of the Generalized Inverse Kinematics (GIK) solver to achieve consistent results ? How can I be sure of getting the maximum reachable configurations? Because of this problem, it appears that sometimes the UR5e can reach certain poses, but other times it cannot, which undermines the reliability of the simulations.
Thank you for your assistance.Hello,
I am trying to generate some valid pick up configurations for a given orientation ( I have 17 different orientations to test) around some points in space with UR5e. I count them as well so that I know the exact number of valid pick up configurations around each point. The thing is, sometimes when I run the simulation for some points, it counts less or more then it did before. So let’s say the result of the first execution for the point A was 16 valid pick up configs around that point, the second time it can be 13 for example instead of 16. Why is this happening ? Should I modify the solver parameters of gik to overcome this ? Because if sometimes it looks like the UR5 can’t reach certain poses but other times it can so it’s not really viable.
Hello,
I am trying to generate valid pick-up configurations for a given orientation with a UR5e robot. I have 17 different orientations to test around specific points in space. For each point, I count the number of valid pick-up configurations to determine the exact number of feasible configurations.
However, I have encountered an inconsistency: the number of valid configurations varies between simulation runs. For instance, for a given point A, the first execution might yield 16 valid configurations, while the second might yield only 13.
Why is this inconsistency happening? Should I modify the solver parameters of the Generalized Inverse Kinematics (GIK) solver to achieve consistent results ? How can I be sure of getting the maximum reachable configurations? Because of this problem, it appears that sometimes the UR5e can reach certain poses, but other times it cannot, which undermines the reliability of the simulations.
Thank you for your assistance. Hello,
I am trying to generate some valid pick up configurations for a given orientation ( I have 17 different orientations to test) around some points in space with UR5e. I count them as well so that I know the exact number of valid pick up configurations around each point. The thing is, sometimes when I run the simulation for some points, it counts less or more then it did before. So let’s say the result of the first execution for the point A was 16 valid pick up configs around that point, the second time it can be 13 for example instead of 16. Why is this happening ? Should I modify the solver parameters of gik to overcome this ? Because if sometimes it looks like the UR5 can’t reach certain poses but other times it can so it’s not really viable.
Hello,
I am trying to generate valid pick-up configurations for a given orientation with a UR5e robot. I have 17 different orientations to test around specific points in space. For each point, I count the number of valid pick-up configurations to determine the exact number of feasible configurations.
However, I have encountered an inconsistency: the number of valid configurations varies between simulation runs. For instance, for a given point A, the first execution might yield 16 valid configurations, while the second might yield only 13.
Why is this inconsistency happening? Should I modify the solver parameters of the Generalized Inverse Kinematics (GIK) solver to achieve consistent results ? How can I be sure of getting the maximum reachable configurations? Because of this problem, it appears that sometimes the UR5e can reach certain poses, but other times it cannot, which undermines the reliability of the simulations.
Thank you for your assistance. matlab, inversekinematics MATLAB Answers — New Questions
BLDC/PMSM parametrization based on datasheet
Hello everyone,
I would like to ask regarding parameterization of BLDC/PMSM based on manufacturer’s datasheet. I have a motor datasheet in which interphase-resistance, induction values and number of poles are given? The datasheet is hereby attached. The circled part is my requirement for motor. Could you please guide how to do I calculate:
D&Q Inductance
Torque/BEMF constant or permanent flux linkage
Phase resistance
I believe many manufacturer do not simply provide constant values. Looking forward to hearing from the expert in this field.
Thank you.Hello everyone,
I would like to ask regarding parameterization of BLDC/PMSM based on manufacturer’s datasheet. I have a motor datasheet in which interphase-resistance, induction values and number of poles are given? The datasheet is hereby attached. The circled part is my requirement for motor. Could you please guide how to do I calculate:
D&Q Inductance
Torque/BEMF constant or permanent flux linkage
Phase resistance
I believe many manufacturer do not simply provide constant values. Looking forward to hearing from the expert in this field.
Thank you. Hello everyone,
I would like to ask regarding parameterization of BLDC/PMSM based on manufacturer’s datasheet. I have a motor datasheet in which interphase-resistance, induction values and number of poles are given? The datasheet is hereby attached. The circled part is my requirement for motor. Could you please guide how to do I calculate:
D&Q Inductance
Torque/BEMF constant or permanent flux linkage
Phase resistance
I believe many manufacturer do not simply provide constant values. Looking forward to hearing from the expert in this field.
Thank you. electric_motor_control, pmsm, bldc, motor_parameterization MATLAB Answers — New Questions
Final few iterations of a parfor loop slow down by a factor of 10
I have a regular for loop which calls a function 44 times. Each iteration takes about 32 seconds to execute in this ordinary for loop. If I use a parfor loop instead, each iteration takes about 8 seconds. However, the final 2 iterations take 10 times as long, 75 and 82 seconds. For example, iteration 22 took 15 seconds in an ordinary for loop, and 75 seconds in the parfor loop, because it happened to be executed as the last iteration. This problem only occurs with the final couple of iterations, never in the middle of the rest of the computation. It occurs with differing datasets. Again, those same iterations , if run in a regular for loop, do not take an inordinate amount of time.
I have preallocated the variables, and don’t use global variables.
What is going on? How can I avoid this?I have a regular for loop which calls a function 44 times. Each iteration takes about 32 seconds to execute in this ordinary for loop. If I use a parfor loop instead, each iteration takes about 8 seconds. However, the final 2 iterations take 10 times as long, 75 and 82 seconds. For example, iteration 22 took 15 seconds in an ordinary for loop, and 75 seconds in the parfor loop, because it happened to be executed as the last iteration. This problem only occurs with the final couple of iterations, never in the middle of the rest of the computation. It occurs with differing datasets. Again, those same iterations , if run in a regular for loop, do not take an inordinate amount of time.
I have preallocated the variables, and don’t use global variables.
What is going on? How can I avoid this? I have a regular for loop which calls a function 44 times. Each iteration takes about 32 seconds to execute in this ordinary for loop. If I use a parfor loop instead, each iteration takes about 8 seconds. However, the final 2 iterations take 10 times as long, 75 and 82 seconds. For example, iteration 22 took 15 seconds in an ordinary for loop, and 75 seconds in the parfor loop, because it happened to be executed as the last iteration. This problem only occurs with the final couple of iterations, never in the middle of the rest of the computation. It occurs with differing datasets. Again, those same iterations , if run in a regular for loop, do not take an inordinate amount of time.
I have preallocated the variables, and don’t use global variables.
What is going on? How can I avoid this? parfor, slow MATLAB Answers — New Questions
Unequal, custom, non-evenly spaced colorbar intervals
I have a colorbar ranging from -1000 to 4000 with intervals of 500 throughout. How would I change the colorbar to display intervals so they were spaced 250 from -1000 to 1000, and had an interval of 1000 from 1000 to 4000?I have a colorbar ranging from -1000 to 4000 with intervals of 500 throughout. How would I change the colorbar to display intervals so they were spaced 250 from -1000 to 1000, and had an interval of 1000 from 1000 to 4000? I have a colorbar ranging from -1000 to 4000 with intervals of 500 throughout. How would I change the colorbar to display intervals so they were spaced 250 from -1000 to 1000, and had an interval of 1000 from 1000 to 4000? colorbar MATLAB Answers — New Questions
Is it possible to obtain ANFIS Data for Genetic Algorithm Optimisation in MATLAB?
I use Design Expert to generate regression equations from raw input data. These regression equations are integrated into MATLAB to perform genetic algorithm single and multi-objective optimisation using the MATLAB optimisation tool. I’ve been looking to utilise ANFIS using the MATLAB fuzzy logic designer to fine tune the raw data, so that the fine tuned input data and output data can be used for the optimisation instead.
However, the exports I get from the ANFIS simulation results are not (in my opinion) very clear regarding how I can use these fine-tuned datasets subsequent to training the model and obtaining the Root mean square errors. How can one determine the fine tuned input and output data after the training is complete? I see that the training model generates ranges for each of my membership functions per input but from that range, it is difficult to ascertain whether it can give me a specific dataset of values for input and output compared to the raw input and output data that was entered.
The steps I have performed thus far:
I used 85% (26) of the total data set (30) to train the Sugeno model
I used the remaining 15% (4) of the total data set to validate, from which I got tuned predictions of the 4 reference outputs.
From my observation, System Validation takes the trained model and gives ‘tuned’ predicted values of any dataset that is used for validation
In this regard, it is my assumption that by inputting the full 30 reference data sets would give me tuned versions of themselves as tuned output values, which I can re-inject into Design Expert to obtain a ‘tuned’ regression equation, to be used for MATLAB’s genetic algorithm optimisation.
After trying this, I did get higher R squared values for the regression equation as well, which "kind" of confirmed that this works. However, I have not seen this be done anywhere, nor do I know if my interpretation of how to use the system validation via the fuzzy logic designer to get these tuned outputs is correct.
I’ve also attached a code script that was formulated without the use of the Fuzzy Logic Designer tool to try and ascertain the problem. The ‘idea’ centres around re-integrating the 30 datasets into the validation step this time (even though 26 of them were used to train in the first place), but for the purpose of obtaining tuned versions of themselves before using the tuned versions in Design Expert for generating a ‘tuned’ regression equation for MATLAB’s GA Optimisation. Does this make sense?
I am unsure if these are the right steps. Any advice would be greatly appreciated.
% Load your data
load yourData.mat % Replace with your data file
% Combine inputs and outputs into one dataset
data = [inputs, outputs];
% Split data into training and validation sets
numDataPoints = size(data, 1);
trainRatio = 0.85; % 15% for training
numTrain = round(trainRatio * numDataPoints);
trainData = data(1:numTrain, :);
valData = data(numTrain+1:end, :);
% Generate initial FIS using genfis1
numMFs = 4; % Example number of membership functions
fis = genfis1(trainData, numMFs);
% Train the ANFIS model with validation data
[anfisModel, trainError, stepSize, valError] = anfis(trainData, fis, [], [], valData);
% Display the final model structure
disp(anfisModel);
% Assume ‘newInputs’ is the data for which you want to predict the outputs
newInputs = inputs; % Replace with your actual new input data
% Evaluate the model to get the fine-tuned outputs
fineTunedOutputs = evalfis(newInputs, anfisModel);
% Display the fine-tuned outputs
disp(fineTunedOutputs);I use Design Expert to generate regression equations from raw input data. These regression equations are integrated into MATLAB to perform genetic algorithm single and multi-objective optimisation using the MATLAB optimisation tool. I’ve been looking to utilise ANFIS using the MATLAB fuzzy logic designer to fine tune the raw data, so that the fine tuned input data and output data can be used for the optimisation instead.
However, the exports I get from the ANFIS simulation results are not (in my opinion) very clear regarding how I can use these fine-tuned datasets subsequent to training the model and obtaining the Root mean square errors. How can one determine the fine tuned input and output data after the training is complete? I see that the training model generates ranges for each of my membership functions per input but from that range, it is difficult to ascertain whether it can give me a specific dataset of values for input and output compared to the raw input and output data that was entered.
The steps I have performed thus far:
I used 85% (26) of the total data set (30) to train the Sugeno model
I used the remaining 15% (4) of the total data set to validate, from which I got tuned predictions of the 4 reference outputs.
From my observation, System Validation takes the trained model and gives ‘tuned’ predicted values of any dataset that is used for validation
In this regard, it is my assumption that by inputting the full 30 reference data sets would give me tuned versions of themselves as tuned output values, which I can re-inject into Design Expert to obtain a ‘tuned’ regression equation, to be used for MATLAB’s genetic algorithm optimisation.
After trying this, I did get higher R squared values for the regression equation as well, which "kind" of confirmed that this works. However, I have not seen this be done anywhere, nor do I know if my interpretation of how to use the system validation via the fuzzy logic designer to get these tuned outputs is correct.
I’ve also attached a code script that was formulated without the use of the Fuzzy Logic Designer tool to try and ascertain the problem. The ‘idea’ centres around re-integrating the 30 datasets into the validation step this time (even though 26 of them were used to train in the first place), but for the purpose of obtaining tuned versions of themselves before using the tuned versions in Design Expert for generating a ‘tuned’ regression equation for MATLAB’s GA Optimisation. Does this make sense?
I am unsure if these are the right steps. Any advice would be greatly appreciated.
% Load your data
load yourData.mat % Replace with your data file
% Combine inputs and outputs into one dataset
data = [inputs, outputs];
% Split data into training and validation sets
numDataPoints = size(data, 1);
trainRatio = 0.85; % 15% for training
numTrain = round(trainRatio * numDataPoints);
trainData = data(1:numTrain, :);
valData = data(numTrain+1:end, :);
% Generate initial FIS using genfis1
numMFs = 4; % Example number of membership functions
fis = genfis1(trainData, numMFs);
% Train the ANFIS model with validation data
[anfisModel, trainError, stepSize, valError] = anfis(trainData, fis, [], [], valData);
% Display the final model structure
disp(anfisModel);
% Assume ‘newInputs’ is the data for which you want to predict the outputs
newInputs = inputs; % Replace with your actual new input data
% Evaluate the model to get the fine-tuned outputs
fineTunedOutputs = evalfis(newInputs, anfisModel);
% Display the fine-tuned outputs
disp(fineTunedOutputs); I use Design Expert to generate regression equations from raw input data. These regression equations are integrated into MATLAB to perform genetic algorithm single and multi-objective optimisation using the MATLAB optimisation tool. I’ve been looking to utilise ANFIS using the MATLAB fuzzy logic designer to fine tune the raw data, so that the fine tuned input data and output data can be used for the optimisation instead.
However, the exports I get from the ANFIS simulation results are not (in my opinion) very clear regarding how I can use these fine-tuned datasets subsequent to training the model and obtaining the Root mean square errors. How can one determine the fine tuned input and output data after the training is complete? I see that the training model generates ranges for each of my membership functions per input but from that range, it is difficult to ascertain whether it can give me a specific dataset of values for input and output compared to the raw input and output data that was entered.
The steps I have performed thus far:
I used 85% (26) of the total data set (30) to train the Sugeno model
I used the remaining 15% (4) of the total data set to validate, from which I got tuned predictions of the 4 reference outputs.
From my observation, System Validation takes the trained model and gives ‘tuned’ predicted values of any dataset that is used for validation
In this regard, it is my assumption that by inputting the full 30 reference data sets would give me tuned versions of themselves as tuned output values, which I can re-inject into Design Expert to obtain a ‘tuned’ regression equation, to be used for MATLAB’s genetic algorithm optimisation.
After trying this, I did get higher R squared values for the regression equation as well, which "kind" of confirmed that this works. However, I have not seen this be done anywhere, nor do I know if my interpretation of how to use the system validation via the fuzzy logic designer to get these tuned outputs is correct.
I’ve also attached a code script that was formulated without the use of the Fuzzy Logic Designer tool to try and ascertain the problem. The ‘idea’ centres around re-integrating the 30 datasets into the validation step this time (even though 26 of them were used to train in the first place), but for the purpose of obtaining tuned versions of themselves before using the tuned versions in Design Expert for generating a ‘tuned’ regression equation for MATLAB’s GA Optimisation. Does this make sense?
I am unsure if these are the right steps. Any advice would be greatly appreciated.
% Load your data
load yourData.mat % Replace with your data file
% Combine inputs and outputs into one dataset
data = [inputs, outputs];
% Split data into training and validation sets
numDataPoints = size(data, 1);
trainRatio = 0.85; % 15% for training
numTrain = round(trainRatio * numDataPoints);
trainData = data(1:numTrain, :);
valData = data(numTrain+1:end, :);
% Generate initial FIS using genfis1
numMFs = 4; % Example number of membership functions
fis = genfis1(trainData, numMFs);
% Train the ANFIS model with validation data
[anfisModel, trainError, stepSize, valError] = anfis(trainData, fis, [], [], valData);
% Display the final model structure
disp(anfisModel);
% Assume ‘newInputs’ is the data for which you want to predict the outputs
newInputs = inputs; % Replace with your actual new input data
% Evaluate the model to get the fine-tuned outputs
fineTunedOutputs = evalfis(newInputs, anfisModel);
% Display the fine-tuned outputs
disp(fineTunedOutputs); adaptive neuro fuzzy inference system, anfis, single objective optimisation, multi-objective optimisation, genetic algorithm, fuzzy logic designer, design expert, regression equation, objective function MATLAB Answers — New Questions
How to assign a function to an Excel cell
I have been using xlswrite to write Excel functions into cells in an Excel spreadsheet. When opening the spreadsheet the functions evaluate as expected. Now Mathworks is calling xlswrite "not recommended". I’ve been unable to find a way to accomplish the same thing without xlswrite. How can I use another builtin Matlab function to perform the same as the xlswrite?
% Ways to write to Excel
FN = ‘TestFile.xlsx’;
% Put some values into the test file
Vals = num2cell(rand(10,3));
writecell(Vals, FN, ‘range’, ‘a1’);
% Function for an Excel cell
XFunction = {‘=SUM(B1:B10)’};
% This creates a function in Excel that works
xlswrite(FN, XFunction, 1, ‘D1’);
% This does not
writecell(XFunction, FN, ‘Range’, ‘D2’)
winopen(FN)I have been using xlswrite to write Excel functions into cells in an Excel spreadsheet. When opening the spreadsheet the functions evaluate as expected. Now Mathworks is calling xlswrite "not recommended". I’ve been unable to find a way to accomplish the same thing without xlswrite. How can I use another builtin Matlab function to perform the same as the xlswrite?
% Ways to write to Excel
FN = ‘TestFile.xlsx’;
% Put some values into the test file
Vals = num2cell(rand(10,3));
writecell(Vals, FN, ‘range’, ‘a1’);
% Function for an Excel cell
XFunction = {‘=SUM(B1:B10)’};
% This creates a function in Excel that works
xlswrite(FN, XFunction, 1, ‘D1’);
% This does not
writecell(XFunction, FN, ‘Range’, ‘D2’)
winopen(FN) I have been using xlswrite to write Excel functions into cells in an Excel spreadsheet. When opening the spreadsheet the functions evaluate as expected. Now Mathworks is calling xlswrite "not recommended". I’ve been unable to find a way to accomplish the same thing without xlswrite. How can I use another builtin Matlab function to perform the same as the xlswrite?
% Ways to write to Excel
FN = ‘TestFile.xlsx’;
% Put some values into the test file
Vals = num2cell(rand(10,3));
writecell(Vals, FN, ‘range’, ‘a1’);
% Function for an Excel cell
XFunction = {‘=SUM(B1:B10)’};
% This creates a function in Excel that works
xlswrite(FN, XFunction, 1, ‘D1’);
% This does not
writecell(XFunction, FN, ‘Range’, ‘D2’)
winopen(FN) excel, functions MATLAB Answers — New Questions
Speed up Simulink Model using World Magnetic Model (WMM2020)
I’m attempting to generate Magnetometer measurements for a CubeSat in Simulink using the WMM2020 (World Magnetic Model) Block but when I run a simulation with the block connected the simulation drastically slows down; from 500s instaneously to sticking at 1e-07.
Has anyone used the WMM2020 block and encountered similar problems? If so what did you do to speed up the simulation?I’m attempting to generate Magnetometer measurements for a CubeSat in Simulink using the WMM2020 (World Magnetic Model) Block but when I run a simulation with the block connected the simulation drastically slows down; from 500s instaneously to sticking at 1e-07.
Has anyone used the WMM2020 block and encountered similar problems? If so what did you do to speed up the simulation? I’m attempting to generate Magnetometer measurements for a CubeSat in Simulink using the WMM2020 (World Magnetic Model) Block but when I run a simulation with the block connected the simulation drastically slows down; from 500s instaneously to sticking at 1e-07.
Has anyone used the WMM2020 block and encountered similar problems? If so what did you do to speed up the simulation? wmm2020, simulink, cubesat MATLAB Answers — New Questions
Tune FIS with Training Data
In the example contained in the Fuzzy logic user guide documentation by mathworks, Tune Fuzzy Inference System at the Command Line, page 225, I understand the code used for tuning the FIS, but i dont know how they come up with tunedfismpgprediction.mat . below is the sample code:
[data,name] = loadGasData;
X = data(:,1:6);
Y = data(:,7);
trnX = X(1:2:end,:); % Training input data set
trnY = Y(1:2:end,:); % Training output data set
vldX = X(2:2:end,:); % Validation input data set
vldY = Y(2:2:end,:); % Validation output data set
dataRange = [min(data)’ max(data)’];
fisin = mamfis;
for i = 1:6
fisin = addInput(fisin,dataRange(i,:),’Name’,name(i),’NumMFs’,2);
end
fisin = addOutput(fisin,dataRange(7,:),’Name’,name(7),’NumMFs’,64);
figure
plotfis(fisin)
options = tunefisOptions(‘Method’,’particleswarm’,…
‘OptimizationType’,’learning’, …
‘NumMaxRules’,64);
options.MethodOptions.MaxIterations = 20;
rng(‘default’)
runtunefis = false;
%% This is the stage where am confused, I dont know how they get tunedfismpgprediction.mat
if runtunefis
fisout1 = tunefis(fisin,[],trnX,trnY,options); %#ok
else
tunedfis = load(‘tunedfismpgprediction.mat’);
fisout1 = tunedfis.fisout1;
fprintf(‘Training RMSE = %.3f MPGn’,calculateRMSE(fisout1,trnX,trnY));
end
plotfis(fisout1)In the example contained in the Fuzzy logic user guide documentation by mathworks, Tune Fuzzy Inference System at the Command Line, page 225, I understand the code used for tuning the FIS, but i dont know how they come up with tunedfismpgprediction.mat . below is the sample code:
[data,name] = loadGasData;
X = data(:,1:6);
Y = data(:,7);
trnX = X(1:2:end,:); % Training input data set
trnY = Y(1:2:end,:); % Training output data set
vldX = X(2:2:end,:); % Validation input data set
vldY = Y(2:2:end,:); % Validation output data set
dataRange = [min(data)’ max(data)’];
fisin = mamfis;
for i = 1:6
fisin = addInput(fisin,dataRange(i,:),’Name’,name(i),’NumMFs’,2);
end
fisin = addOutput(fisin,dataRange(7,:),’Name’,name(7),’NumMFs’,64);
figure
plotfis(fisin)
options = tunefisOptions(‘Method’,’particleswarm’,…
‘OptimizationType’,’learning’, …
‘NumMaxRules’,64);
options.MethodOptions.MaxIterations = 20;
rng(‘default’)
runtunefis = false;
%% This is the stage where am confused, I dont know how they get tunedfismpgprediction.mat
if runtunefis
fisout1 = tunefis(fisin,[],trnX,trnY,options); %#ok
else
tunedfis = load(‘tunedfismpgprediction.mat’);
fisout1 = tunedfis.fisout1;
fprintf(‘Training RMSE = %.3f MPGn’,calculateRMSE(fisout1,trnX,trnY));
end
plotfis(fisout1) In the example contained in the Fuzzy logic user guide documentation by mathworks, Tune Fuzzy Inference System at the Command Line, page 225, I understand the code used for tuning the FIS, but i dont know how they come up with tunedfismpgprediction.mat . below is the sample code:
[data,name] = loadGasData;
X = data(:,1:6);
Y = data(:,7);
trnX = X(1:2:end,:); % Training input data set
trnY = Y(1:2:end,:); % Training output data set
vldX = X(2:2:end,:); % Validation input data set
vldY = Y(2:2:end,:); % Validation output data set
dataRange = [min(data)’ max(data)’];
fisin = mamfis;
for i = 1:6
fisin = addInput(fisin,dataRange(i,:),’Name’,name(i),’NumMFs’,2);
end
fisin = addOutput(fisin,dataRange(7,:),’Name’,name(7),’NumMFs’,64);
figure
plotfis(fisin)
options = tunefisOptions(‘Method’,’particleswarm’,…
‘OptimizationType’,’learning’, …
‘NumMaxRules’,64);
options.MethodOptions.MaxIterations = 20;
rng(‘default’)
runtunefis = false;
%% This is the stage where am confused, I dont know how they get tunedfismpgprediction.mat
if runtunefis
fisout1 = tunefis(fisin,[],trnX,trnY,options); %#ok
else
tunedfis = load(‘tunedfismpgprediction.mat’);
fisout1 = tunedfis.fisout1;
fprintf(‘Training RMSE = %.3f MPGn’,calculateRMSE(fisout1,trnX,trnY));
end
plotfis(fisout1) tunefis, fis, fuzzy inference system MATLAB Answers — New Questions
Midpoint integration with for loop
Hi,
Computing a numerical integration with the Midpoint Method I’m struggling with the output of my function, while with Euler I got the expected result, with this method I’m getting a different graphical solution far away than the analytical solution (and the euler’s one). What could be wrongly specified?
Thanks for your help.
% Midpoint method
% General information
L = 0.61; % [m]
G = 9.81; % gamma [m/s^2]
% Sampling interval
h = 0.1;
%h = 0.05;
%h = 0.01;
ti = 0; % Initial time
tf = 4; % Final time
t = ti:h:tf; % Time vector
function [md] = midpoint(t,L,G,h)
% Initial Value problem
md = zeros(2, length(t));
md(1,1) = pi/40;
for i = 1:length(t)-1
pmd = md(2,i) + (h/2) + (-G/L)*sin(md(1,i)) + (h/2) * [md(2,i); (-G/L)*sin(md(1,i))];
md(:,i+1) = md(:,i) + h * pmd;
end
endHi,
Computing a numerical integration with the Midpoint Method I’m struggling with the output of my function, while with Euler I got the expected result, with this method I’m getting a different graphical solution far away than the analytical solution (and the euler’s one). What could be wrongly specified?
Thanks for your help.
% Midpoint method
% General information
L = 0.61; % [m]
G = 9.81; % gamma [m/s^2]
% Sampling interval
h = 0.1;
%h = 0.05;
%h = 0.01;
ti = 0; % Initial time
tf = 4; % Final time
t = ti:h:tf; % Time vector
function [md] = midpoint(t,L,G,h)
% Initial Value problem
md = zeros(2, length(t));
md(1,1) = pi/40;
for i = 1:length(t)-1
pmd = md(2,i) + (h/2) + (-G/L)*sin(md(1,i)) + (h/2) * [md(2,i); (-G/L)*sin(md(1,i))];
md(:,i+1) = md(:,i) + h * pmd;
end
end Hi,
Computing a numerical integration with the Midpoint Method I’m struggling with the output of my function, while with Euler I got the expected result, with this method I’m getting a different graphical solution far away than the analytical solution (and the euler’s one). What could be wrongly specified?
Thanks for your help.
% Midpoint method
% General information
L = 0.61; % [m]
G = 9.81; % gamma [m/s^2]
% Sampling interval
h = 0.1;
%h = 0.05;
%h = 0.01;
ti = 0; % Initial time
tf = 4; % Final time
t = ti:h:tf; % Time vector
function [md] = midpoint(t,L,G,h)
% Initial Value problem
md = zeros(2, length(t));
md(1,1) = pi/40;
for i = 1:length(t)-1
pmd = md(2,i) + (h/2) + (-G/L)*sin(md(1,i)) + (h/2) * [md(2,i); (-G/L)*sin(md(1,i))];
md(:,i+1) = md(:,i) + h * pmd;
end
end midpoint, numerical integration, for loop, function, indexing, iteration MATLAB Answers — New Questions
How to get Simulink HDL Coder RAM with non power of 2 depth.
Simulink RAMs ask the user for the address bits instead of the data depth, and then generate HDL using a power-of-2 depth. This may result in extra, unused RAMs to be inferred by a synthesis tool. For example if your RAM could be implemented in 3 chained Block RAMs of depth 2^10 for a total depth of 3*2^10 but due to the Simulink RAM specifying a depth of 2^12 (based on needing 12 address bits) the tool will use 4 Block RAMs instead of the minimum 3.
Is it possible to get Simulink to generate RAM HDL with a specified depth? The output code would look something like below:
module SimpleDualPortRAM_generic
(clk,
wr_din,
wr_addr,
wr_en,
rd_addr,
dout);
parameter integer DataWidth = 9;
parameter integer DataDepth = 12288;
localparam AddrWidth = $clog2(DataDepth);
input clk;
input [DataWidth – 1:0] wr_din; // parameterized width
input [AddrWidth – 1:0] wr_addr; // parameterized width
input wr_en; // ufix1
input [AddrWidth – 1:0] rd_addr; // parameterized width
output [DataWidth – 1:0] dout; // parameterized width
reg [DataWidth – 1:0] ram [DataDepth – 1:0];
reg [DataWidth – 1:0] data_int;
always @(posedge clk)
begin : SimpleDualPortRAM_generic_process
if (wr_en == 1’b1) begin
ram[wr_addr] <= wr_din;
end
data_int <= ram[rd_addr];
end
assign dout = data_int;
endmodule // SimpleDualPortRAM_genericSimulink RAMs ask the user for the address bits instead of the data depth, and then generate HDL using a power-of-2 depth. This may result in extra, unused RAMs to be inferred by a synthesis tool. For example if your RAM could be implemented in 3 chained Block RAMs of depth 2^10 for a total depth of 3*2^10 but due to the Simulink RAM specifying a depth of 2^12 (based on needing 12 address bits) the tool will use 4 Block RAMs instead of the minimum 3.
Is it possible to get Simulink to generate RAM HDL with a specified depth? The output code would look something like below:
module SimpleDualPortRAM_generic
(clk,
wr_din,
wr_addr,
wr_en,
rd_addr,
dout);
parameter integer DataWidth = 9;
parameter integer DataDepth = 12288;
localparam AddrWidth = $clog2(DataDepth);
input clk;
input [DataWidth – 1:0] wr_din; // parameterized width
input [AddrWidth – 1:0] wr_addr; // parameterized width
input wr_en; // ufix1
input [AddrWidth – 1:0] rd_addr; // parameterized width
output [DataWidth – 1:0] dout; // parameterized width
reg [DataWidth – 1:0] ram [DataDepth – 1:0];
reg [DataWidth – 1:0] data_int;
always @(posedge clk)
begin : SimpleDualPortRAM_generic_process
if (wr_en == 1’b1) begin
ram[wr_addr] <= wr_din;
end
data_int <= ram[rd_addr];
end
assign dout = data_int;
endmodule // SimpleDualPortRAM_generic Simulink RAMs ask the user for the address bits instead of the data depth, and then generate HDL using a power-of-2 depth. This may result in extra, unused RAMs to be inferred by a synthesis tool. For example if your RAM could be implemented in 3 chained Block RAMs of depth 2^10 for a total depth of 3*2^10 but due to the Simulink RAM specifying a depth of 2^12 (based on needing 12 address bits) the tool will use 4 Block RAMs instead of the minimum 3.
Is it possible to get Simulink to generate RAM HDL with a specified depth? The output code would look something like below:
module SimpleDualPortRAM_generic
(clk,
wr_din,
wr_addr,
wr_en,
rd_addr,
dout);
parameter integer DataWidth = 9;
parameter integer DataDepth = 12288;
localparam AddrWidth = $clog2(DataDepth);
input clk;
input [DataWidth – 1:0] wr_din; // parameterized width
input [AddrWidth – 1:0] wr_addr; // parameterized width
input wr_en; // ufix1
input [AddrWidth – 1:0] rd_addr; // parameterized width
output [DataWidth – 1:0] dout; // parameterized width
reg [DataWidth – 1:0] ram [DataDepth – 1:0];
reg [DataWidth – 1:0] data_int;
always @(posedge clk)
begin : SimpleDualPortRAM_generic_process
if (wr_en == 1’b1) begin
ram[wr_addr] <= wr_din;
end
data_int <= ram[rd_addr];
end
assign dout = data_int;
endmodule // SimpleDualPortRAM_generic simulink ram, ram depth, ram, dual port ram MATLAB Answers — New Questions
How is the Shape factor for laminar flow viscous friction calculated in Regenerator pipe (G) in Stirling Simscape model.
In the model’s parameter script it has various properties for the regenerator including reynold’s number. i know how reynold’s number is caluclated but i cant understand how the assumingly conductive shape factor is calculated and why is it put into Shape factor for laminar flow viscous friction tab in pipe block
regenerator.geometry.length = geometry.displacer_piston.length – 2*crank_wheel.slidercrank_disp.crank_radius;
regenerator.geometry.area = A;
regenerator.geometry.hydraulic_diam = 4*A/P;
regenerator.fric_therm.length_add = 0.01*regenerator.geometry.length;
regenerator.fric_therm.roughness = 15e-6; %[m]
regenerator.fric_therm.Re_lam = 2000;
regenerator.fric_therm.Re_tur = 4000;
regenerator.fric_therm.shape_factor = 64;
regenerator.fric_therm.Nu_lam = 3.66;In the model’s parameter script it has various properties for the regenerator including reynold’s number. i know how reynold’s number is caluclated but i cant understand how the assumingly conductive shape factor is calculated and why is it put into Shape factor for laminar flow viscous friction tab in pipe block
regenerator.geometry.length = geometry.displacer_piston.length – 2*crank_wheel.slidercrank_disp.crank_radius;
regenerator.geometry.area = A;
regenerator.geometry.hydraulic_diam = 4*A/P;
regenerator.fric_therm.length_add = 0.01*regenerator.geometry.length;
regenerator.fric_therm.roughness = 15e-6; %[m]
regenerator.fric_therm.Re_lam = 2000;
regenerator.fric_therm.Re_tur = 4000;
regenerator.fric_therm.shape_factor = 64;
regenerator.fric_therm.Nu_lam = 3.66; In the model’s parameter script it has various properties for the regenerator including reynold’s number. i know how reynold’s number is caluclated but i cant understand how the assumingly conductive shape factor is calculated and why is it put into Shape factor for laminar flow viscous friction tab in pipe block
regenerator.geometry.length = geometry.displacer_piston.length – 2*crank_wheel.slidercrank_disp.crank_radius;
regenerator.geometry.area = A;
regenerator.geometry.hydraulic_diam = 4*A/P;
regenerator.fric_therm.length_add = 0.01*regenerator.geometry.length;
regenerator.fric_therm.roughness = 15e-6; %[m]
regenerator.fric_therm.Re_lam = 2000;
regenerator.fric_therm.Re_tur = 4000;
regenerator.fric_therm.shape_factor = 64;
regenerator.fric_therm.Nu_lam = 3.66; simscape MATLAB Answers — New Questions
Can I use Matlab 2024a license with 2022b client software version
I am going to update my license for 2024a and my license has that version listed. I want to update the license but keep the client software at 2022b for now. I will update the client software at a later date and need the backwards compatibility temporily. Is it possible to update my license to 2024a but keep the 2022b client software? Thank you.I am going to update my license for 2024a and my license has that version listed. I want to update the license but keep the client software at 2022b for now. I will update the client software at a later date and need the backwards compatibility temporily. Is it possible to update my license to 2024a but keep the 2022b client software? Thank you. I am going to update my license for 2024a and my license has that version listed. I want to update the license but keep the client software at 2022b for now. I will update the client software at a later date and need the backwards compatibility temporily. Is it possible to update my license to 2024a but keep the 2022b client software? Thank you. license, 2024a, 2022b MATLAB Answers — New Questions
How to do differentiation in Matlab
clc;
clear;
THT = 0:12:360;
L_spm = [67.14387343 67.08087868 71.27139857 77.8011002 83.48598354 86.53313448 86.96218524 86.54264509 86.55222711 86.96002063 86.43128473 83.48041917 77.77271123 71.24225453 67.07111986 67.25745156 67.08157624 71.23009025 77.76475253 83.46615144 86.42639244 86.96777069 86.54247287 86.56340306 86.9412182 86.52945688 83.49766473 77.78259172 71.25635182 67.06788196 67.14602485];
How to differentiate L_spm with respect to THT? Thanks.clc;
clear;
THT = 0:12:360;
L_spm = [67.14387343 67.08087868 71.27139857 77.8011002 83.48598354 86.53313448 86.96218524 86.54264509 86.55222711 86.96002063 86.43128473 83.48041917 77.77271123 71.24225453 67.07111986 67.25745156 67.08157624 71.23009025 77.76475253 83.46615144 86.42639244 86.96777069 86.54247287 86.56340306 86.9412182 86.52945688 83.49766473 77.78259172 71.25635182 67.06788196 67.14602485];
How to differentiate L_spm with respect to THT? Thanks. clc;
clear;
THT = 0:12:360;
L_spm = [67.14387343 67.08087868 71.27139857 77.8011002 83.48598354 86.53313448 86.96218524 86.54264509 86.55222711 86.96002063 86.43128473 83.48041917 77.77271123 71.24225453 67.07111986 67.25745156 67.08157624 71.23009025 77.76475253 83.46615144 86.42639244 86.96777069 86.54247287 86.56340306 86.9412182 86.52945688 83.49766473 77.78259172 71.25635182 67.06788196 67.14602485];
How to differentiate L_spm with respect to THT? Thanks. differentiation MATLAB Answers — New Questions
How to customise Polar Plots – Part 2
Following on from a question I had a year ago (How to customise Polar Plots – MATLAB Answers – MATLAB Central (mathworks.com)), I am in need of shifting the location of the chart/axis titles. My polar plot has a range of 180^o: from-90 to 90 with 0 at the middle bottom, but because I’ve had to increase the axis fontweight to bold, the Raxis values and label overlap with the chart title. When I try to relocate the chart title horizontally to the left, it is going off the screen. Can someone advise, I’ve included the relevant code below:
polarplot(th2-pi/2,Rs); Ax = gca; Ax.ThetaZeroLocation = ‘bottom’; Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2; Ax.FontSize = 16; Ax.FontWeight = ‘bold’; Ax.RLim = [0 1e-7]; Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2); Ax.ThetaTickLabel = compose(‘%d’,-90:10:90);
title(‘I want this chart title to be wholly visible in the top-left hand corner of the screen’,’FontSize’,20,’FontWeight’,’bold’);Following on from a question I had a year ago (How to customise Polar Plots – MATLAB Answers – MATLAB Central (mathworks.com)), I am in need of shifting the location of the chart/axis titles. My polar plot has a range of 180^o: from-90 to 90 with 0 at the middle bottom, but because I’ve had to increase the axis fontweight to bold, the Raxis values and label overlap with the chart title. When I try to relocate the chart title horizontally to the left, it is going off the screen. Can someone advise, I’ve included the relevant code below:
polarplot(th2-pi/2,Rs); Ax = gca; Ax.ThetaZeroLocation = ‘bottom’; Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2; Ax.FontSize = 16; Ax.FontWeight = ‘bold’; Ax.RLim = [0 1e-7]; Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2); Ax.ThetaTickLabel = compose(‘%d’,-90:10:90);
title(‘I want this chart title to be wholly visible in the top-left hand corner of the screen’,’FontSize’,20,’FontWeight’,’bold’); Following on from a question I had a year ago (How to customise Polar Plots – MATLAB Answers – MATLAB Central (mathworks.com)), I am in need of shifting the location of the chart/axis titles. My polar plot has a range of 180^o: from-90 to 90 with 0 at the middle bottom, but because I’ve had to increase the axis fontweight to bold, the Raxis values and label overlap with the chart title. When I try to relocate the chart title horizontally to the left, it is going off the screen. Can someone advise, I’ve included the relevant code below:
polarplot(th2-pi/2,Rs); Ax = gca; Ax.ThetaZeroLocation = ‘bottom’; Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2; Ax.FontSize = 16; Ax.FontWeight = ‘bold’; Ax.RLim = [0 1e-7]; Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2); Ax.ThetaTickLabel = compose(‘%d’,-90:10:90);
title(‘I want this chart title to be wholly visible in the top-left hand corner of the screen’,’FontSize’,20,’FontWeight’,’bold’); polarplot, axis, title MATLAB Answers — New Questions
How to connect MATLAB with EES(engineering equation solver) using MATLAB code?
I have wrote some MATLAB code, using some parameters from genetic algorithm input to EES for calculating thermodynamic properties. Then I get the calculated result and output from EES to matlab. But I met some problems, here is the connecting matlab code below:
Because I have bought the academic version EES software, I input the parameters into EES by writing parameter value in dat file, and EES got the data from dat file. However, the calculating process stopped in the EES interface, no command have executed after that. If the program runs successfully, EES should return calculating results to MATLAB within seconds.
I have no idea what wrong with it, can anyone help me? I can’t thank you enough.I have wrote some MATLAB code, using some parameters from genetic algorithm input to EES for calculating thermodynamic properties. Then I get the calculated result and output from EES to matlab. But I met some problems, here is the connecting matlab code below:
Because I have bought the academic version EES software, I input the parameters into EES by writing parameter value in dat file, and EES got the data from dat file. However, the calculating process stopped in the EES interface, no command have executed after that. If the program runs successfully, EES should return calculating results to MATLAB within seconds.
I have no idea what wrong with it, can anyone help me? I can’t thank you enough. I have wrote some MATLAB code, using some parameters from genetic algorithm input to EES for calculating thermodynamic properties. Then I get the calculated result and output from EES to matlab. But I met some problems, here is the connecting matlab code below:
Because I have bought the academic version EES software, I input the parameters into EES by writing parameter value in dat file, and EES got the data from dat file. However, the calculating process stopped in the EES interface, no command have executed after that. If the program runs successfully, EES should return calculating results to MATLAB within seconds.
I have no idea what wrong with it, can anyone help me? I can’t thank you enough. engineering equation solver, ees, interaction MATLAB Answers — New Questions