Tag Archives: matlab
Can I “collapse all in” the editor like in the help browser
When I work in a class I usually collapse all my methods (functions) to get a better overwiew. BUT I cant seem to find a way of collapsing all of them at once, instead I have to do them one by one…
Im I just missing something super simple or is matlab actually lacking this feature in the Editor?When I work in a class I usually collapse all my methods (functions) to get a better overwiew. BUT I cant seem to find a way of collapsing all of them at once, instead I have to do them one by one…
Im I just missing something super simple or is matlab actually lacking this feature in the Editor? When I work in a class I usually collapse all my methods (functions) to get a better overwiew. BUT I cant seem to find a way of collapsing all of them at once, instead I have to do them one by one…
Im I just missing something super simple or is matlab actually lacking this feature in the Editor? matlab, editor MATLAB Answers — New Questions
Setting inputs formats for nested Neural ODE
Hi all,
I am constructing a NN that nests a Neural ODE. The NN has two datasets as inputs: i) The initial values of internal states (InitialValue) that are used to feed the Neural ODE and, ii) The sequences (input_2) that are included in the NN after the Neural ODE. The input_2 and the outputs of the Neural ODE must be summed.
I tried creating the entries of the NN in cell and dlarray format. For the last one I also defined the dimensions ‘CBT’ and/or ‘CB’ according the structure of the dataserie, nevertheles the problem persists.
The error I got is the following
%% Generate data
data_1 = randn(1,1000);
data_2 = randn(1,1000);
tspan = 1:1:50;
InitialValue = data_1(:,1:end-length(tspan))’;
indices = 1:length(InitialValue);
targets = arrayfun(@(i) data_1(:, i + tspan), indices, ‘UniformOutput’, false)’;
input_2 = arrayfun(@(i) data_2(:, i + tspan), indices, ‘UniformOutput’, false)’;
%% Create neuralnetwork
% NeuralODE layers
OdeLayer = [fullyConnectedLayer(5)
tanhLayer
fullyConnectedLayer(1)];
OdeNet = dlnetwork(OdeLayer,Initialize=false);
% Main layer
net = dlnetwork;
Layers =[featureInputLayer(1,’Name’,’Input 1′)
neuralODELayer(OdeNet,tspan,"Name",’OdeLayer’,’GradientMode’,’adjoint’)];
% add extra input for adition to NeuralODE output
net = addLayers(net, Layers);
net = addLayers(net, sequenceInputLayer(1,’Name’,’Input 2′));
net = addLayers(net, additionLayer(2,’Name’,’adition’));
% connect layers
net = connectLayers(net,’Input 2′,’adition/in2′);
net = connectLayers(net,’OdeLayer’,’adition/in1′);
%% Train Network
% gather inputs and targets
input_1_ds = arrayDatastore(InitialValue,"OutputType","same");
input_2_ds = arrayDatastore(input_2,"OutputType","same");
target_ds = arrayDatastore(targets,"OutputType","same");
cds = combine(input_1_ds, input_2_ds, target_ds);
opt = trainingOptions("adam");
% training
net = trainnet(cds,net,"l2loss",opt);
Thanks in advance for your feedback and comments.Hi all,
I am constructing a NN that nests a Neural ODE. The NN has two datasets as inputs: i) The initial values of internal states (InitialValue) that are used to feed the Neural ODE and, ii) The sequences (input_2) that are included in the NN after the Neural ODE. The input_2 and the outputs of the Neural ODE must be summed.
I tried creating the entries of the NN in cell and dlarray format. For the last one I also defined the dimensions ‘CBT’ and/or ‘CB’ according the structure of the dataserie, nevertheles the problem persists.
The error I got is the following
%% Generate data
data_1 = randn(1,1000);
data_2 = randn(1,1000);
tspan = 1:1:50;
InitialValue = data_1(:,1:end-length(tspan))’;
indices = 1:length(InitialValue);
targets = arrayfun(@(i) data_1(:, i + tspan), indices, ‘UniformOutput’, false)’;
input_2 = arrayfun(@(i) data_2(:, i + tspan), indices, ‘UniformOutput’, false)’;
%% Create neuralnetwork
% NeuralODE layers
OdeLayer = [fullyConnectedLayer(5)
tanhLayer
fullyConnectedLayer(1)];
OdeNet = dlnetwork(OdeLayer,Initialize=false);
% Main layer
net = dlnetwork;
Layers =[featureInputLayer(1,’Name’,’Input 1′)
neuralODELayer(OdeNet,tspan,"Name",’OdeLayer’,’GradientMode’,’adjoint’)];
% add extra input for adition to NeuralODE output
net = addLayers(net, Layers);
net = addLayers(net, sequenceInputLayer(1,’Name’,’Input 2′));
net = addLayers(net, additionLayer(2,’Name’,’adition’));
% connect layers
net = connectLayers(net,’Input 2′,’adition/in2′);
net = connectLayers(net,’OdeLayer’,’adition/in1′);
%% Train Network
% gather inputs and targets
input_1_ds = arrayDatastore(InitialValue,"OutputType","same");
input_2_ds = arrayDatastore(input_2,"OutputType","same");
target_ds = arrayDatastore(targets,"OutputType","same");
cds = combine(input_1_ds, input_2_ds, target_ds);
opt = trainingOptions("adam");
% training
net = trainnet(cds,net,"l2loss",opt);
Thanks in advance for your feedback and comments. Hi all,
I am constructing a NN that nests a Neural ODE. The NN has two datasets as inputs: i) The initial values of internal states (InitialValue) that are used to feed the Neural ODE and, ii) The sequences (input_2) that are included in the NN after the Neural ODE. The input_2 and the outputs of the Neural ODE must be summed.
I tried creating the entries of the NN in cell and dlarray format. For the last one I also defined the dimensions ‘CBT’ and/or ‘CB’ according the structure of the dataserie, nevertheles the problem persists.
The error I got is the following
%% Generate data
data_1 = randn(1,1000);
data_2 = randn(1,1000);
tspan = 1:1:50;
InitialValue = data_1(:,1:end-length(tspan))’;
indices = 1:length(InitialValue);
targets = arrayfun(@(i) data_1(:, i + tspan), indices, ‘UniformOutput’, false)’;
input_2 = arrayfun(@(i) data_2(:, i + tspan), indices, ‘UniformOutput’, false)’;
%% Create neuralnetwork
% NeuralODE layers
OdeLayer = [fullyConnectedLayer(5)
tanhLayer
fullyConnectedLayer(1)];
OdeNet = dlnetwork(OdeLayer,Initialize=false);
% Main layer
net = dlnetwork;
Layers =[featureInputLayer(1,’Name’,’Input 1′)
neuralODELayer(OdeNet,tspan,"Name",’OdeLayer’,’GradientMode’,’adjoint’)];
% add extra input for adition to NeuralODE output
net = addLayers(net, Layers);
net = addLayers(net, sequenceInputLayer(1,’Name’,’Input 2′));
net = addLayers(net, additionLayer(2,’Name’,’adition’));
% connect layers
net = connectLayers(net,’Input 2′,’adition/in2′);
net = connectLayers(net,’OdeLayer’,’adition/in1′);
%% Train Network
% gather inputs and targets
input_1_ds = arrayDatastore(InitialValue,"OutputType","same");
input_2_ds = arrayDatastore(input_2,"OutputType","same");
target_ds = arrayDatastore(targets,"OutputType","same");
cds = combine(input_1_ds, input_2_ds, target_ds);
opt = trainingOptions("adam");
% training
net = trainnet(cds,net,"l2loss",opt);
Thanks in advance for your feedback and comments. neural ode, neural network, deep learning MATLAB Answers — New Questions
Frequency change through load change in grid connected VSC rectifier based system. System detunes when connected to synchronous generator model.
In 10kW VSC Rectifier system connected to grid in matlab, i want to induce a frequency change through load change. In this model 3 phase voltage source model is represented as grid and when load change is induced it shows no deviation. Then, I have modelled the source with the synchronous generator model. As a standalone system, the synchronous generator model works fine with AC loads. But when the synchronous generator model is used as a source for the VSC Rectifier based system, the system detunes and desired performance is not achieved.In 10kW VSC Rectifier system connected to grid in matlab, i want to induce a frequency change through load change. In this model 3 phase voltage source model is represented as grid and when load change is induced it shows no deviation. Then, I have modelled the source with the synchronous generator model. As a standalone system, the synchronous generator model works fine with AC loads. But when the synchronous generator model is used as a source for the VSC Rectifier based system, the system detunes and desired performance is not achieved. In 10kW VSC Rectifier system connected to grid in matlab, i want to induce a frequency change through load change. In this model 3 phase voltage source model is represented as grid and when load change is induced it shows no deviation. Then, I have modelled the source with the synchronous generator model. As a standalone system, the synchronous generator model works fine with AC loads. But when the synchronous generator model is used as a source for the VSC Rectifier based system, the system detunes and desired performance is not achieved. frequency change through load change, matlab simulink, synchronous generator model, voltage source converter MATLAB Answers — New Questions
How to calculate the length of the longest crack in this image automatically ?
How to highlight those cracks in this image and calculate their lengths?How to highlight those cracks in this image and calculate their lengths? How to highlight those cracks in this image and calculate their lengths? image binary crack length, crack MATLAB Answers — New Questions
How to read the fieldname from a field in ThinkSpeak when using ThinkSpeak library for Arduino
How to read the fieldname from a field in ThinkSpeak when using ThinkSpeak library for Arduino?How to read the fieldname from a field in ThinkSpeak when using ThinkSpeak library for Arduino? How to read the fieldname from a field in ThinkSpeak when using ThinkSpeak library for Arduino? thingspeak, fieldname MATLAB Answers — New Questions
how can improve limitation of input simulation function of quantum circuit.limitation is number of qubits
helo
I have problem when use simulation function for quantum. number of qubits is limited by 20-30 qubits. how can imrove this problem by 130 qubits?helo
I have problem when use simulation function for quantum. number of qubits is limited by 20-30 qubits. how can imrove this problem by 130 qubits? helo
I have problem when use simulation function for quantum. number of qubits is limited by 20-30 qubits. how can imrove this problem by 130 qubits? quantum, number of qubit MATLAB Answers — New Questions
can i use my STM32 nucleo with an Arduino Block on Simulink?
I don’t see STM board is avalible when setup board on arduinoI don’t see STM board is avalible when setup board on arduino I don’t see STM board is avalible when setup board on arduino arduino, stm32 nucleo MATLAB Answers — New Questions
How to access tiff files
Hello MatLab world.
I have several .tiif files in my hands that I need to access, read and extract certain data from. As it is the first time that I’m handlind .tiff, I need your lights.
I have 102 folders (daily data from 01/07/2019 to 10/10/2019: 102 days=102 folders) . Each folder contains a zipped file with 73 .tiff files. These .tiff files contain hourly temperature data.
First thing I must extract only the first 24 of the 73 as they represent the 24 hourly values of the first day. Second thing, I must access the data these 24 .tiff contain and locate the temperature values I need.
I am copying the few lines of code I have written and please enlighten me:
cd ‘C:ProjectsLIFE ASTIC.3THESSTemperature’
t = Tiff(‘THESSTemperature_20190701T0000Z.tiff’,’r’);
filename = ‘THESSTemperature_20190701T0000Z.tiff’;
imageData = read(t);
imshow(imageData);
info = imfinfo(filename)
Thank you in advance!Hello MatLab world.
I have several .tiif files in my hands that I need to access, read and extract certain data from. As it is the first time that I’m handlind .tiff, I need your lights.
I have 102 folders (daily data from 01/07/2019 to 10/10/2019: 102 days=102 folders) . Each folder contains a zipped file with 73 .tiff files. These .tiff files contain hourly temperature data.
First thing I must extract only the first 24 of the 73 as they represent the 24 hourly values of the first day. Second thing, I must access the data these 24 .tiff contain and locate the temperature values I need.
I am copying the few lines of code I have written and please enlighten me:
cd ‘C:ProjectsLIFE ASTIC.3THESSTemperature’
t = Tiff(‘THESSTemperature_20190701T0000Z.tiff’,’r’);
filename = ‘THESSTemperature_20190701T0000Z.tiff’;
imageData = read(t);
imshow(imageData);
info = imfinfo(filename)
Thank you in advance! Hello MatLab world.
I have several .tiif files in my hands that I need to access, read and extract certain data from. As it is the first time that I’m handlind .tiff, I need your lights.
I have 102 folders (daily data from 01/07/2019 to 10/10/2019: 102 days=102 folders) . Each folder contains a zipped file with 73 .tiff files. These .tiff files contain hourly temperature data.
First thing I must extract only the first 24 of the 73 as they represent the 24 hourly values of the first day. Second thing, I must access the data these 24 .tiff contain and locate the temperature values I need.
I am copying the few lines of code I have written and please enlighten me:
cd ‘C:ProjectsLIFE ASTIC.3THESSTemperature’
t = Tiff(‘THESSTemperature_20190701T0000Z.tiff’,’r’);
filename = ‘THESSTemperature_20190701T0000Z.tiff’;
imageData = read(t);
imshow(imageData);
info = imfinfo(filename)
Thank you in advance! .tiff files MATLAB Answers — New Questions
How to limit operating element size of array in Simulink
Hi,
I am trying to make a reference Simulink model for different projects.
One of difference between each pjoject is operating size of array.
eg. Project A : using 12 elements(Max) / Project B : using 10 elements / Project C: 8 elements….
I want to change the operating range for each project with max(12) array on reference model, to optimize operating speed.
How can I change the operating element size of array with parameter?
I want to avoid changing array size for each project for compatibility with other modules.
Thank you in advance.Hi,
I am trying to make a reference Simulink model for different projects.
One of difference between each pjoject is operating size of array.
eg. Project A : using 12 elements(Max) / Project B : using 10 elements / Project C: 8 elements….
I want to change the operating range for each project with max(12) array on reference model, to optimize operating speed.
How can I change the operating element size of array with parameter?
I want to avoid changing array size for each project for compatibility with other modules.
Thank you in advance. Hi,
I am trying to make a reference Simulink model for different projects.
One of difference between each pjoject is operating size of array.
eg. Project A : using 12 elements(Max) / Project B : using 10 elements / Project C: 8 elements….
I want to change the operating range for each project with max(12) array on reference model, to optimize operating speed.
How can I change the operating element size of array with parameter?
I want to avoid changing array size for each project for compatibility with other modules.
Thank you in advance. simulink, simulink array MATLAB Answers — New Questions
batch file processing (.txt files) for data analysis
Hi, I have more than 200 ‘.txt’ files to process the data. Each file has same number of coloumns, i.e 10, but number of rows vary. Imported data to array variables and created a structure of each file. And further processing data of individual file for analysis.
Hy=importdata(‘hyde0710p1c1.15txt’);
Ii=importdata(‘iisc0710p1c1.15txt’);
save(‘Hy710.txt’,’Hy’); save(‘Ii710.txt’,’Ii’);
hyde_org=struct(‘GPSTOW’,Hy(:,1),’PRN’,Hy(:,2),’EL’,Hy(:,3),’AZ’,Hy(:,4),’IPPMLat’,Hy(:,5),’IPPGeoLong’,Hy(:,6),’IPPGeoLat’,Hy(:,7),’SlantCodeTEC’,Hy(:,8),’SlantSmoothTEC’,Hy(:,9),’VTEC’,Hy(:,10));
iisc_org=struct(‘GPSTOW’,Ii(:,1),’PRN’,Ii(:,2),’EL’,Ii(:,3),’AZ’,Ii(:,4),’IPPMLat’,Ii(:,5),’IPPGeoLong’,Ii(:,6),’IPPGeoLat’,Ii(:,7),’SlantCodeTEC’,Ii(:,8),’SlantSmoothTEC’,Ii(:,9),’VTEC’,Ii(:,10));
But,now I need to append all the data(to append rows one after the other file’s) of 200 files in ta single new file for processing.
Can anyone help please?Hi, I have more than 200 ‘.txt’ files to process the data. Each file has same number of coloumns, i.e 10, but number of rows vary. Imported data to array variables and created a structure of each file. And further processing data of individual file for analysis.
Hy=importdata(‘hyde0710p1c1.15txt’);
Ii=importdata(‘iisc0710p1c1.15txt’);
save(‘Hy710.txt’,’Hy’); save(‘Ii710.txt’,’Ii’);
hyde_org=struct(‘GPSTOW’,Hy(:,1),’PRN’,Hy(:,2),’EL’,Hy(:,3),’AZ’,Hy(:,4),’IPPMLat’,Hy(:,5),’IPPGeoLong’,Hy(:,6),’IPPGeoLat’,Hy(:,7),’SlantCodeTEC’,Hy(:,8),’SlantSmoothTEC’,Hy(:,9),’VTEC’,Hy(:,10));
iisc_org=struct(‘GPSTOW’,Ii(:,1),’PRN’,Ii(:,2),’EL’,Ii(:,3),’AZ’,Ii(:,4),’IPPMLat’,Ii(:,5),’IPPGeoLong’,Ii(:,6),’IPPGeoLat’,Ii(:,7),’SlantCodeTEC’,Ii(:,8),’SlantSmoothTEC’,Ii(:,9),’VTEC’,Ii(:,10));
But,now I need to append all the data(to append rows one after the other file’s) of 200 files in ta single new file for processing.
Can anyone help please? Hi, I have more than 200 ‘.txt’ files to process the data. Each file has same number of coloumns, i.e 10, but number of rows vary. Imported data to array variables and created a structure of each file. And further processing data of individual file for analysis.
Hy=importdata(‘hyde0710p1c1.15txt’);
Ii=importdata(‘iisc0710p1c1.15txt’);
save(‘Hy710.txt’,’Hy’); save(‘Ii710.txt’,’Ii’);
hyde_org=struct(‘GPSTOW’,Hy(:,1),’PRN’,Hy(:,2),’EL’,Hy(:,3),’AZ’,Hy(:,4),’IPPMLat’,Hy(:,5),’IPPGeoLong’,Hy(:,6),’IPPGeoLat’,Hy(:,7),’SlantCodeTEC’,Hy(:,8),’SlantSmoothTEC’,Hy(:,9),’VTEC’,Hy(:,10));
iisc_org=struct(‘GPSTOW’,Ii(:,1),’PRN’,Ii(:,2),’EL’,Ii(:,3),’AZ’,Ii(:,4),’IPPMLat’,Ii(:,5),’IPPGeoLong’,Ii(:,6),’IPPGeoLat’,Ii(:,7),’SlantCodeTEC’,Ii(:,8),’SlantSmoothTEC’,Ii(:,9),’VTEC’,Ii(:,10));
But,now I need to append all the data(to append rows one after the other file’s) of 200 files in ta single new file for processing.
Can anyone help please? batch file .txt file processing MATLAB Answers — New Questions
How to retrieve the Matlab Release version of simulink file using python
Hi, I want to know if there is an API or any method to know in which version of Matlab a simulink file has been developed without opening Matlab.
I have 100+ simulink files and I want to know in which version these files have been developed. All files are created after Matlab 2017.
I am using Python to parse through all models and looking for some mechanism/idea by which we get the matlab version.
Is there any metadata informatio present .slx files.
Thanks in advance.Hi, I want to know if there is an API or any method to know in which version of Matlab a simulink file has been developed without opening Matlab.
I have 100+ simulink files and I want to know in which version these files have been developed. All files are created after Matlab 2017.
I am using Python to parse through all models and looking for some mechanism/idea by which we get the matlab version.
Is there any metadata informatio present .slx files.
Thanks in advance. Hi, I want to know if there is an API or any method to know in which version of Matlab a simulink file has been developed without opening Matlab.
I have 100+ simulink files and I want to know in which version these files have been developed. All files are created after Matlab 2017.
I am using Python to parse through all models and looking for some mechanism/idea by which we get the matlab version.
Is there any metadata informatio present .slx files.
Thanks in advance. matlab, simulink, python MATLAB Answers — New Questions
How to get the HOG descriptor visualization as an image?
I need the visualizations of the HOG descriptor as an image that i can extract regions for my further analysis.I need the visualizations of the HOG descriptor as an image that i can extract regions for my further analysis. I need the visualizations of the HOG descriptor as an image that i can extract regions for my further analysis. hog, hog features, hog visualization MATLAB Answers — New Questions
Markov chain
I have three states for a time series and I would like to predict the 4th state using markove chain.
My data has unknown distribution with known mean and std.
I am not sure how to estimate the "transition matrix" and "observation matrix"?
Using "hmmestimate" I need to have the "seq" and "states" which there are no clear documentation in Matlab as what the format is!
Do MLE (maximum likelihood estimamtion) or EM (expectation maximization)other possibilities for computing transition matrix?
Is there any example of real data implementation as of how to use markov chain?
Thanks for your helpI have three states for a time series and I would like to predict the 4th state using markove chain.
My data has unknown distribution with known mean and std.
I am not sure how to estimate the "transition matrix" and "observation matrix"?
Using "hmmestimate" I need to have the "seq" and "states" which there are no clear documentation in Matlab as what the format is!
Do MLE (maximum likelihood estimamtion) or EM (expectation maximization)other possibilities for computing transition matrix?
Is there any example of real data implementation as of how to use markov chain?
Thanks for your help I have three states for a time series and I would like to predict the 4th state using markove chain.
My data has unknown distribution with known mean and std.
I am not sure how to estimate the "transition matrix" and "observation matrix"?
Using "hmmestimate" I need to have the "seq" and "states" which there are no clear documentation in Matlab as what the format is!
Do MLE (maximum likelihood estimamtion) or EM (expectation maximization)other possibilities for computing transition matrix?
Is there any example of real data implementation as of how to use markov chain?
Thanks for your help markov chain MATLAB Answers — New Questions
Simulation Implementation issue for C2000MCU F28379D
I am trying a sample example to glow LED using MCU C2000 LaunchPad F28379D using example simulink model. After compilation program builds and run without any error but there is no pulse at the configured PIN of the MCU. How do i rectify this.I am trying a sample example to glow LED using MCU C2000 LaunchPad F28379D using example simulink model. After compilation program builds and run without any error but there is no pulse at the configured PIN of the MCU. How do i rectify this. I am trying a sample example to glow LED using MCU C2000 LaunchPad F28379D using example simulink model. After compilation program builds and run without any error but there is no pulse at the configured PIN of the MCU. How do i rectify this. c2000, f28379dlaunchpad, simulation MATLAB Answers — New Questions
How to get visualization of HOGfeatures
I used following code to extract HOG feature from an image in gui
if true
[HogFeature, visualization]= extractHOGFeatures(filepath,1);
axes(handles.axes3);
plot(visualization);
end
where filepath is my image, but when I start that part of code I get error "Error using extractHOGFeatures
Expected POINTS to be of size Mx2 when it is actually size 1×1."
What´s wrong?I used following code to extract HOG feature from an image in gui
if true
[HogFeature, visualization]= extractHOGFeatures(filepath,1);
axes(handles.axes3);
plot(visualization);
end
where filepath is my image, but when I start that part of code I get error "Error using extractHOGFeatures
Expected POINTS to be of size Mx2 when it is actually size 1×1."
What´s wrong? I used following code to extract HOG feature from an image in gui
if true
[HogFeature, visualization]= extractHOGFeatures(filepath,1);
axes(handles.axes3);
plot(visualization);
end
where filepath is my image, but when I start that part of code I get error "Error using extractHOGFeatures
Expected POINTS to be of size Mx2 when it is actually size 1×1."
What´s wrong? gui, extracthogfeatures MATLAB Answers — New Questions
taking difference of 2 surf figures of different sizes
One is to compare two solutions and study the error by taking their difference. The two solutions are two surf figures generated by surf(x1,y1,z1) and surf(x2,y2,z2) but x1 and x2 are different in size and so are y1, y2, z1, z2. One can think of this as two solutions z1, z2 obtained on 2 meshes. Is there a smart way of taking z1-z2 and surf’ing it?One is to compare two solutions and study the error by taking their difference. The two solutions are two surf figures generated by surf(x1,y1,z1) and surf(x2,y2,z2) but x1 and x2 are different in size and so are y1, y2, z1, z2. One can think of this as two solutions z1, z2 obtained on 2 meshes. Is there a smart way of taking z1-z2 and surf’ing it? One is to compare two solutions and study the error by taking their difference. The two solutions are two surf figures generated by surf(x1,y1,z1) and surf(x2,y2,z2) but x1 and x2 are different in size and so are y1, y2, z1, z2. One can think of this as two solutions z1, z2 obtained on 2 meshes. Is there a smart way of taking z1-z2 and surf’ing it? surf MATLAB Answers — New Questions
Fit a linear equation to obtain coefficients (constants)
Hi, I have a linear equation P = a + bM + c(Y-1) + d(M(Y-1)) where a, b, c and d are coefficients (constants). P, Y and M are known properties. Specifically, there are multiple P values, each with their corresponding Y and M values. How do I use matlab or excel to fit the data to the equation above to obatin the a, b, c & d coefficients? Please see image below. So each P value has 2 Y values and 2 M values. Any ideas?Hi, I have a linear equation P = a + bM + c(Y-1) + d(M(Y-1)) where a, b, c and d are coefficients (constants). P, Y and M are known properties. Specifically, there are multiple P values, each with their corresponding Y and M values. How do I use matlab or excel to fit the data to the equation above to obatin the a, b, c & d coefficients? Please see image below. So each P value has 2 Y values and 2 M values. Any ideas? Hi, I have a linear equation P = a + bM + c(Y-1) + d(M(Y-1)) where a, b, c and d are coefficients (constants). P, Y and M are known properties. Specifically, there are multiple P values, each with their corresponding Y and M values. How do I use matlab or excel to fit the data to the equation above to obatin the a, b, c & d coefficients? Please see image below. So each P value has 2 Y values and 2 M values. Any ideas? linear fit, curve fitting MATLAB Answers — New Questions
Error flag for infeasibility in nonlinear mpc.
I am getting the error flag -2 for my nonlinear mpc design despite their being no constraints. If there is no constraints, how is there infeasibility? The only way I can get it to be feasible is to make the intial condition the exact same as the reference. If there is deviation the problem is infeasible
clear all
nx = 4;
ny = 2;
nu = 3;
nlobj = nlmpc(nx,ny,nu);
nlobj.Ts = 0.1;
nlobj.PredictionHorizon = 10;
nlobj.ControlHorizon = 10;
nlobj.Model.StateFcn = @mystateFunctionREDUCED;
nlobj.Model.IsContinuousTime = true;
nlobj.Model.NumberOfParameters = 5;
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
nlobj.Model.OutputFcn = @OutputFcn
;
x0 = [1;0;pi/8;0];
mv = [m*g+1; 0; 0];
lastMV = mv;
%validateFcns(nlobj, x0, u0, [], {rho,l,g,J,m});
nloptions = nlmpcmoveopt;
nloptions.Parameters = {rho,l,g,J,m};
Duration = 1;
Ts = 0.01;
xHistory = x0′;
yref = [1;pi/9];
%nlobj.Weights.OutputVariables = [3 3];
%nlobj.Weights.ManipulatedVariablesRate = 0.1;
% nlobj.States(1).Min = 0;
% nlobj.States(1).Max = 20;
% nlobj.States(3).Min = 0;
% nlobj.States(3).Max = pi;
%nlobj.Optimization.CustomIneqConFcn = "myIneqConFunctionreduced";
nlobj.Weights.ManipulatedVariablesRate = [0 0 0];
nlobj.Weights.OutputVariables = [1 1];
%nlobj.Weights.ECR = 0;
Tarray = [];
Uarray = [];
for k = 1:(Duration/Ts)
xk = xHistory(k,:);
% Compute optimal control moves
[mv,nloptions,info] = nlmpcmove(nlobj,xk,lastMV,yref’,[],nloptions);
info
%disp(mv)
% Implement first optimal control move
ODEFUN = @(t,xk) statefcn(xk,mv);
[TOUT,XOUT] = ode45(ODEFUN,[0 Ts], xHistory(k,:)’);
x0 = mystateFunctionREDUCED(x0,mv,rho,l,g,J,m)*Ts+x0;
uHistory(k+1,:) = mv’;
lastMV = mv;
%[t,y] = ode15s(@mystateFunction,[0 Ts],[2 0]);
%T = (m*x0(1)*x0(4)^2-m*g*sin(x0(3))+mv(1)*sin(x0(3)+x0(5))-m*rho/l*mv(3))/(1+m*rho^2/l);
%Tarray = [Tarray T];
Uarray = [Uarray mv];
xHistory(k+1,:) = XOUT(end,:);
%opt.Slack0
%T
%par = m*x0(1).*x0(4).^2-m*g*sin(x0(3))
% Save plant states
%xHistory = [xHistory x0];
end
function z = mystateFunctionREDUCED(x,u,rho,l,g,J,m)
z = zeros(4,1);
% rho = params(1);
% l = params(2);
% %T = params(3);
% g = params(3);
% J = params(4);
% m = params(5);
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
end
function y = OutputFcn(x,u,rho,l,g,J,m)
y = zeros(2,1);
y(1) = x(1);
y(2) = x(3);
end
function f = statefcn(in1,in2)
%QuadrotorStateFcn
% F = QuadrotorStateFcn(IN1,IN2)
% This function was generated by the Symbolic Math Toolbox version 24.1.
% 09-Jan-2025 19:28:44
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
x = in1;
u = in2;
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
f = [z(1);z(2);z(3);z(4)];
endI am getting the error flag -2 for my nonlinear mpc design despite their being no constraints. If there is no constraints, how is there infeasibility? The only way I can get it to be feasible is to make the intial condition the exact same as the reference. If there is deviation the problem is infeasible
clear all
nx = 4;
ny = 2;
nu = 3;
nlobj = nlmpc(nx,ny,nu);
nlobj.Ts = 0.1;
nlobj.PredictionHorizon = 10;
nlobj.ControlHorizon = 10;
nlobj.Model.StateFcn = @mystateFunctionREDUCED;
nlobj.Model.IsContinuousTime = true;
nlobj.Model.NumberOfParameters = 5;
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
nlobj.Model.OutputFcn = @OutputFcn
;
x0 = [1;0;pi/8;0];
mv = [m*g+1; 0; 0];
lastMV = mv;
%validateFcns(nlobj, x0, u0, [], {rho,l,g,J,m});
nloptions = nlmpcmoveopt;
nloptions.Parameters = {rho,l,g,J,m};
Duration = 1;
Ts = 0.01;
xHistory = x0′;
yref = [1;pi/9];
%nlobj.Weights.OutputVariables = [3 3];
%nlobj.Weights.ManipulatedVariablesRate = 0.1;
% nlobj.States(1).Min = 0;
% nlobj.States(1).Max = 20;
% nlobj.States(3).Min = 0;
% nlobj.States(3).Max = pi;
%nlobj.Optimization.CustomIneqConFcn = "myIneqConFunctionreduced";
nlobj.Weights.ManipulatedVariablesRate = [0 0 0];
nlobj.Weights.OutputVariables = [1 1];
%nlobj.Weights.ECR = 0;
Tarray = [];
Uarray = [];
for k = 1:(Duration/Ts)
xk = xHistory(k,:);
% Compute optimal control moves
[mv,nloptions,info] = nlmpcmove(nlobj,xk,lastMV,yref’,[],nloptions);
info
%disp(mv)
% Implement first optimal control move
ODEFUN = @(t,xk) statefcn(xk,mv);
[TOUT,XOUT] = ode45(ODEFUN,[0 Ts], xHistory(k,:)’);
x0 = mystateFunctionREDUCED(x0,mv,rho,l,g,J,m)*Ts+x0;
uHistory(k+1,:) = mv’;
lastMV = mv;
%[t,y] = ode15s(@mystateFunction,[0 Ts],[2 0]);
%T = (m*x0(1)*x0(4)^2-m*g*sin(x0(3))+mv(1)*sin(x0(3)+x0(5))-m*rho/l*mv(3))/(1+m*rho^2/l);
%Tarray = [Tarray T];
Uarray = [Uarray mv];
xHistory(k+1,:) = XOUT(end,:);
%opt.Slack0
%T
%par = m*x0(1).*x0(4).^2-m*g*sin(x0(3))
% Save plant states
%xHistory = [xHistory x0];
end
function z = mystateFunctionREDUCED(x,u,rho,l,g,J,m)
z = zeros(4,1);
% rho = params(1);
% l = params(2);
% %T = params(3);
% g = params(3);
% J = params(4);
% m = params(5);
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
end
function y = OutputFcn(x,u,rho,l,g,J,m)
y = zeros(2,1);
y(1) = x(1);
y(2) = x(3);
end
function f = statefcn(in1,in2)
%QuadrotorStateFcn
% F = QuadrotorStateFcn(IN1,IN2)
% This function was generated by the Symbolic Math Toolbox version 24.1.
% 09-Jan-2025 19:28:44
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
x = in1;
u = in2;
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
f = [z(1);z(2);z(3);z(4)];
end I am getting the error flag -2 for my nonlinear mpc design despite their being no constraints. If there is no constraints, how is there infeasibility? The only way I can get it to be feasible is to make the intial condition the exact same as the reference. If there is deviation the problem is infeasible
clear all
nx = 4;
ny = 2;
nu = 3;
nlobj = nlmpc(nx,ny,nu);
nlobj.Ts = 0.1;
nlobj.PredictionHorizon = 10;
nlobj.ControlHorizon = 10;
nlobj.Model.StateFcn = @mystateFunctionREDUCED;
nlobj.Model.IsContinuousTime = true;
nlobj.Model.NumberOfParameters = 5;
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
nlobj.Model.OutputFcn = @OutputFcn
;
x0 = [1;0;pi/8;0];
mv = [m*g+1; 0; 0];
lastMV = mv;
%validateFcns(nlobj, x0, u0, [], {rho,l,g,J,m});
nloptions = nlmpcmoveopt;
nloptions.Parameters = {rho,l,g,J,m};
Duration = 1;
Ts = 0.01;
xHistory = x0′;
yref = [1;pi/9];
%nlobj.Weights.OutputVariables = [3 3];
%nlobj.Weights.ManipulatedVariablesRate = 0.1;
% nlobj.States(1).Min = 0;
% nlobj.States(1).Max = 20;
% nlobj.States(3).Min = 0;
% nlobj.States(3).Max = pi;
%nlobj.Optimization.CustomIneqConFcn = "myIneqConFunctionreduced";
nlobj.Weights.ManipulatedVariablesRate = [0 0 0];
nlobj.Weights.OutputVariables = [1 1];
%nlobj.Weights.ECR = 0;
Tarray = [];
Uarray = [];
for k = 1:(Duration/Ts)
xk = xHistory(k,:);
% Compute optimal control moves
[mv,nloptions,info] = nlmpcmove(nlobj,xk,lastMV,yref’,[],nloptions);
info
%disp(mv)
% Implement first optimal control move
ODEFUN = @(t,xk) statefcn(xk,mv);
[TOUT,XOUT] = ode45(ODEFUN,[0 Ts], xHistory(k,:)’);
x0 = mystateFunctionREDUCED(x0,mv,rho,l,g,J,m)*Ts+x0;
uHistory(k+1,:) = mv’;
lastMV = mv;
%[t,y] = ode15s(@mystateFunction,[0 Ts],[2 0]);
%T = (m*x0(1)*x0(4)^2-m*g*sin(x0(3))+mv(1)*sin(x0(3)+x0(5))-m*rho/l*mv(3))/(1+m*rho^2/l);
%Tarray = [Tarray T];
Uarray = [Uarray mv];
xHistory(k+1,:) = XOUT(end,:);
%opt.Slack0
%T
%par = m*x0(1).*x0(4).^2-m*g*sin(x0(3))
% Save plant states
%xHistory = [xHistory x0];
end
function z = mystateFunctionREDUCED(x,u,rho,l,g,J,m)
z = zeros(4,1);
% rho = params(1);
% l = params(2);
% %T = params(3);
% g = params(3);
% J = params(4);
% m = params(5);
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
end
function y = OutputFcn(x,u,rho,l,g,J,m)
y = zeros(2,1);
y(1) = x(1);
y(2) = x(3);
end
function f = statefcn(in1,in2)
%QuadrotorStateFcn
% F = QuadrotorStateFcn(IN1,IN2)
% This function was generated by the Symbolic Math Toolbox version 24.1.
% 09-Jan-2025 19:28:44
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
x = in1;
u = in2;
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
f = [z(1);z(2);z(3);z(4)];
end control, mpc MATLAB Answers — New Questions
tuning paramters in referenced model whithin a Simulink Real-Time model
Previous to R2020b, we can tune the parameter inside the model reference by the command such as:
tPar_a = getparamid(tg, ‘ModelReference1/subsys1/a’,’Value’);
setparam(tg,tPar_a,1);
After I upgrated to R2024a, the above commands are not availble anymore. I can get and set parameters of the top model, but I can not change parameter values insie the model reference and all the parameters in the model reference are not showing in SLRT_explorer neither. Is there anyway to get the parameter values in the model reference and tune them during simulink realtime simulation?Previous to R2020b, we can tune the parameter inside the model reference by the command such as:
tPar_a = getparamid(tg, ‘ModelReference1/subsys1/a’,’Value’);
setparam(tg,tPar_a,1);
After I upgrated to R2024a, the above commands are not availble anymore. I can get and set parameters of the top model, but I can not change parameter values insie the model reference and all the parameters in the model reference are not showing in SLRT_explorer neither. Is there anyway to get the parameter values in the model reference and tune them during simulink realtime simulation? Previous to R2020b, we can tune the parameter inside the model reference by the command such as:
tPar_a = getparamid(tg, ‘ModelReference1/subsys1/a’,’Value’);
setparam(tg,tPar_a,1);
After I upgrated to R2024a, the above commands are not availble anymore. I can get and set parameters of the top model, but I can not change parameter values insie the model reference and all the parameters in the model reference are not showing in SLRT_explorer neither. Is there anyway to get the parameter values in the model reference and tune them during simulink realtime simulation? tuning modelreference parameter MATLAB Answers — New Questions
Why is the Symmetric circle grid not available as an option in the camera calibrator?
Hi all,
I am trying to use the Stereo Camera Calibrator app in MATLAB 2024a, specifically with the ‘Symmetric circle grid’ pattern. But when I go to select this option, it is not available in the drop down menu (See below)
I was also using this app in late 2024 using 2023b and 2024a and the option was available to use but it has since disappeared. I have also tried to access it on 3 different devices and 5 different MATLAB releases (2016b, 2023a, 2023b, 2024a and 2024b) but it seems to have disappeared from all of them. Has it been removed as an option recently? I didn’t find any indication of this in release notes or bug reports.
Any advice on how to fix this problem would be very welcome.
Thank you!Hi all,
I am trying to use the Stereo Camera Calibrator app in MATLAB 2024a, specifically with the ‘Symmetric circle grid’ pattern. But when I go to select this option, it is not available in the drop down menu (See below)
I was also using this app in late 2024 using 2023b and 2024a and the option was available to use but it has since disappeared. I have also tried to access it on 3 different devices and 5 different MATLAB releases (2016b, 2023a, 2023b, 2024a and 2024b) but it seems to have disappeared from all of them. Has it been removed as an option recently? I didn’t find any indication of this in release notes or bug reports.
Any advice on how to fix this problem would be very welcome.
Thank you! Hi all,
I am trying to use the Stereo Camera Calibrator app in MATLAB 2024a, specifically with the ‘Symmetric circle grid’ pattern. But when I go to select this option, it is not available in the drop down menu (See below)
I was also using this app in late 2024 using 2023b and 2024a and the option was available to use but it has since disappeared. I have also tried to access it on 3 different devices and 5 different MATLAB releases (2016b, 2023a, 2023b, 2024a and 2024b) but it seems to have disappeared from all of them. Has it been removed as an option recently? I didn’t find any indication of this in release notes or bug reports.
Any advice on how to fix this problem would be very welcome.
Thank you! computer vision, camera-calibration MATLAB Answers — New Questions