Category: Matlab
Category Archives: Matlab
Unable to create a STM32CubeMX Project using “Embedded Coder Support Package for STMicroelectronics STM32 Processors”
Hello Comunity,
I am trying to create new project for STM32F4xx based boards. But I can not create the create project biuld options in Simulink Hardware implementation. I have attached the screenshot of the error. I have followed the step shown in the msg and tried to do hardware setup. I have already installed required STM32 CubeMX(v6.4.0) and STM32CubeProgrammer(v2.6.0) as recommended by the simulink hardware support package andthe installation paths are also validated. I was able to complete the setup but still it pops up.Hello Comunity,
I am trying to create new project for STM32F4xx based boards. But I can not create the create project biuld options in Simulink Hardware implementation. I have attached the screenshot of the error. I have followed the step shown in the msg and tried to do hardware setup. I have already installed required STM32 CubeMX(v6.4.0) and STM32CubeProgrammer(v2.6.0) as recommended by the simulink hardware support package andthe installation paths are also validated. I was able to complete the setup but still it pops up. Hello Comunity,
I am trying to create new project for STM32F4xx based boards. But I can not create the create project biuld options in Simulink Hardware implementation. I have attached the screenshot of the error. I have followed the step shown in the msg and tried to do hardware setup. I have already installed required STM32 CubeMX(v6.4.0) and STM32CubeProgrammer(v2.6.0) as recommended by the simulink hardware support package andthe installation paths are also validated. I was able to complete the setup but still it pops up. embedded coder support package, stmicroelectronics, stm32f4xx based board, simulink, model configuration MATLAB Answers — New Questions
Problem with validation of the covariance matrix P in the steady state continuous Kalman filter
Hi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
PHi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
P Hi I am trying to verify on simulations that the covariance matrix of the estimation errror is equal to the matrix P provided by the Riccati Solution of a continuous kalman filter. However when I use lsim to simulate and get the covariance of the estimator error vectors the results are different from P. But if I do P*Ts I can see the equivalence.
Why this factor Ts is appearing?
I am using the following code:
clear
close all
clc
% System
A = [-10 -20;35 -50];
B = [1; 1;];
C = [1 0];
D = 0;
Fs = 50000; % Frequency
Ts = 1/Fs; %
t = 0:Ts:10;
L = length(t);
W = [20 0;0 10];
V = 1;
rng(10,’twister’);
w = chol(W, ‘lower’)*randn(2,L);
v = chol(V, ‘lower’)*randn(1,L);
mw = mean(w,2);
mv = mean(v);
v = v – mean(v)*ones(1,length(v));
w = w – mw.*ones(2,length(v));
cov_w = cov(w’);
cov_v = cov(v);
[Lk,P] = lqe(A,eye(2),C,W,V);
% Augmented system with plant and Kalman filter
Aak = [A zeros(2,2); Lk*C A-Lk*C];
Bak = [B eye(2) zeros(2,1); B zeros(2,2) Lk];
sys_obs_mak = ss(Aak,Bak,eye(4),0);
u(1,:) = 1*heaviside(t);
[yk,t,xk] = lsim(sys_obs_mak,[u’ w’ v’],t,[0 0 0 0]); % Simulation
erro = xk(:,1:2)-xk(:,3:4);
cov_erro_lsim = cov(erro)
PTs = P*Ts
P kalman filter MATLAB Answers — New Questions
How do I remove outliers in data so that vectors are of the same length for plotting?
Please see the attached excel file.
X = First column data
Y = Second column data
I have to ensure that both the vectors are of the same length for plotting and curve-fitting purpose. How do I get rid of the outliers in the Y-values such that the corresponding X-values are also lost?Please see the attached excel file.
X = First column data
Y = Second column data
I have to ensure that both the vectors are of the same length for plotting and curve-fitting purpose. How do I get rid of the outliers in the Y-values such that the corresponding X-values are also lost? Please see the attached excel file.
X = First column data
Y = Second column data
I have to ensure that both the vectors are of the same length for plotting and curve-fitting purpose. How do I get rid of the outliers in the Y-values such that the corresponding X-values are also lost? data import, plotting, signal processing, curve fitting MATLAB Answers — New Questions
Is there any feasible method to automated labelling images for a deep learning task, which I have a lot of images to label which is not practically feasible to do manually
I am doing a medical imaging project with MRI images. I hope to develop a deep learning model for this task. But the data I collected is not labelled and I have to label them for each category. Can someone suggest me a method to automate this labelling process where it will be greatly save my time. Thanks in advance. !I am doing a medical imaging project with MRI images. I hope to develop a deep learning model for this task. But the data I collected is not labelled and I have to label them for each category. Can someone suggest me a method to automate this labelling process where it will be greatly save my time. Thanks in advance. ! I am doing a medical imaging project with MRI images. I hope to develop a deep learning model for this task. But the data I collected is not labelled and I have to label them for each category. Can someone suggest me a method to automate this labelling process where it will be greatly save my time. Thanks in advance. ! deep learning, image analysis, image processing, image labelling MATLAB Answers — New Questions
In the PDE toolbox, can I set my Dirichlet boundary condition to a single point rather than the edge?
In the PDEtoolbox, can I set my Dirichlet boundary condition to a single point rather than the edge?
We use the following code (a really small circle) to approximate the Dirichlet boundary condition for a single point (u=220 when x=0 and y=0). I would like to know if there is a method to directly define boundary conditions on a Point instead of an Edge.
Circle = [1,0,0,0.001]’;
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
%Create FE analysis object
GWModel = createpde();
%Create 2-D geometry
%R = [3,4,200,200,-200,-200,100,-100,-100,100]’;
R = [2,4,200,200,-200,-200,100,-100,-100,100]’;
Circle = [1,0,0,0.001]’;
Circle = [Circle;zeros(length(R) – length(Circle),1)];
gd = [R,Circle];
ns = char(‘RectangularDomain’,’Well’); ns = ns’;
sf = ‘RectangularDomain-Well’;
[g,bt] = decsg(gd,sf,ns);
geometryFromEdges(GWModel,g);
figure(1);pdegplot(GWModel,’EdgeLabels’,’on’);xlim([-250,250]), ylim([-150,150]);axis equal
specifyCoefficients(GWModel, ‘m’,0,’d’,0,’c’,1,’a’,0,’f’,0);
%Assume Boundary conditions
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[1,2,3,4], ‘u’,200);
%applyBoundaryCondition(GWModel,’neumann’, ‘Edge’,[1,4], ‘q’,0,’g’,0);
%Create a mesh, max size
hmax = 1.25;
generateMesh(GWModel,’Hmax’,hmax);
GWModel.Mesh
figure(2);pdemesh(GWModel);xlim([-250,250]), ylim([-150,150]);axis equal;
%Solve PDE
results = solvepde(GWModel);
u = results.NodalSolution;
%Compute the flux of the solution and plot the results.
[cgradx,cgrady] = evaluateCGradient(results);
fluxx = -cgradx;
fluxy = -cgrady;
%Plot solution
figure(3)
pdeplot(GWModel,’XYData’,u,’Contour’,’on’,’FlowData’,[fluxx,fluxy])
axis equal
title(‘Numerical Solution’);xlabel(‘x’);ylabel(‘y’)
xlim([-200,200]), ylim([-100,100])In the PDEtoolbox, can I set my Dirichlet boundary condition to a single point rather than the edge?
We use the following code (a really small circle) to approximate the Dirichlet boundary condition for a single point (u=220 when x=0 and y=0). I would like to know if there is a method to directly define boundary conditions on a Point instead of an Edge.
Circle = [1,0,0,0.001]’;
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
%Create FE analysis object
GWModel = createpde();
%Create 2-D geometry
%R = [3,4,200,200,-200,-200,100,-100,-100,100]’;
R = [2,4,200,200,-200,-200,100,-100,-100,100]’;
Circle = [1,0,0,0.001]’;
Circle = [Circle;zeros(length(R) – length(Circle),1)];
gd = [R,Circle];
ns = char(‘RectangularDomain’,’Well’); ns = ns’;
sf = ‘RectangularDomain-Well’;
[g,bt] = decsg(gd,sf,ns);
geometryFromEdges(GWModel,g);
figure(1);pdegplot(GWModel,’EdgeLabels’,’on’);xlim([-250,250]), ylim([-150,150]);axis equal
specifyCoefficients(GWModel, ‘m’,0,’d’,0,’c’,1,’a’,0,’f’,0);
%Assume Boundary conditions
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[1,2,3,4], ‘u’,200);
%applyBoundaryCondition(GWModel,’neumann’, ‘Edge’,[1,4], ‘q’,0,’g’,0);
%Create a mesh, max size
hmax = 1.25;
generateMesh(GWModel,’Hmax’,hmax);
GWModel.Mesh
figure(2);pdemesh(GWModel);xlim([-250,250]), ylim([-150,150]);axis equal;
%Solve PDE
results = solvepde(GWModel);
u = results.NodalSolution;
%Compute the flux of the solution and plot the results.
[cgradx,cgrady] = evaluateCGradient(results);
fluxx = -cgradx;
fluxy = -cgrady;
%Plot solution
figure(3)
pdeplot(GWModel,’XYData’,u,’Contour’,’on’,’FlowData’,[fluxx,fluxy])
axis equal
title(‘Numerical Solution’);xlabel(‘x’);ylabel(‘y’)
xlim([-200,200]), ylim([-100,100]) In the PDEtoolbox, can I set my Dirichlet boundary condition to a single point rather than the edge?
We use the following code (a really small circle) to approximate the Dirichlet boundary condition for a single point (u=220 when x=0 and y=0). I would like to know if there is a method to directly define boundary conditions on a Point instead of an Edge.
Circle = [1,0,0,0.001]’;
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
%Create FE analysis object
GWModel = createpde();
%Create 2-D geometry
%R = [3,4,200,200,-200,-200,100,-100,-100,100]’;
R = [2,4,200,200,-200,-200,100,-100,-100,100]’;
Circle = [1,0,0,0.001]’;
Circle = [Circle;zeros(length(R) – length(Circle),1)];
gd = [R,Circle];
ns = char(‘RectangularDomain’,’Well’); ns = ns’;
sf = ‘RectangularDomain-Well’;
[g,bt] = decsg(gd,sf,ns);
geometryFromEdges(GWModel,g);
figure(1);pdegplot(GWModel,’EdgeLabels’,’on’);xlim([-250,250]), ylim([-150,150]);axis equal
specifyCoefficients(GWModel, ‘m’,0,’d’,0,’c’,1,’a’,0,’f’,0);
%Assume Boundary conditions
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[5,6,7,8],’u’,220);
applyBoundaryCondition(GWModel,’dirichlet’,’Edge’,[1,2,3,4], ‘u’,200);
%applyBoundaryCondition(GWModel,’neumann’, ‘Edge’,[1,4], ‘q’,0,’g’,0);
%Create a mesh, max size
hmax = 1.25;
generateMesh(GWModel,’Hmax’,hmax);
GWModel.Mesh
figure(2);pdemesh(GWModel);xlim([-250,250]), ylim([-150,150]);axis equal;
%Solve PDE
results = solvepde(GWModel);
u = results.NodalSolution;
%Compute the flux of the solution and plot the results.
[cgradx,cgrady] = evaluateCGradient(results);
fluxx = -cgradx;
fluxy = -cgrady;
%Plot solution
figure(3)
pdeplot(GWModel,’XYData’,u,’Contour’,’on’,’FlowData’,[fluxx,fluxy])
axis equal
title(‘Numerical Solution’);xlabel(‘x’);ylabel(‘y’)
xlim([-200,200]), ylim([-100,100]) pde, dirichlet boundary condition, point input, hydrology MATLAB Answers — New Questions
训练多输出数据时报错“数据类型无效。响应必须为双精度或单精度向量。”
train_x_n为36×2double,train_y_n为36×9double,但model=TreeBagger(tree(i,j), train_x_n, train_y_n, ……一行报错“数据类型无效。响应必须为双精度或单精度向量。”(Invalid data type. Response must be a double or single vector.)
当把train_y_n改成36×1时便不报错,请问如何使它能训练多输出数据?
train_x_n=ones(36,2);
train_y_n=ones(36,9);
[tree,leaf] = meshgrid(80:10:200,1:1:10);
bestRMSE_RF = 1;
% 网格搜索
for i=1:size(leaf,1)
for j=1:size(tree,2)
model=TreeBagger(tree(i,j), train_x_n, train_y_n, OOBPredictorImportance=’on’,Method=’regression’, OOBPrediction=’on’,MinLeafSize=leaf(i,j));
[~,~,RMSE,~]=Test(model,train_x_n,train_y,PSo);
if RMSE<bestRMSE_RF
bestRMSE_RF=RMSE;
besttree=tree(i,j);
bestleaf=leaf(i,j);
model_RF=model;
end
end
endtrain_x_n为36×2double,train_y_n为36×9double,但model=TreeBagger(tree(i,j), train_x_n, train_y_n, ……一行报错“数据类型无效。响应必须为双精度或单精度向量。”(Invalid data type. Response must be a double or single vector.)
当把train_y_n改成36×1时便不报错,请问如何使它能训练多输出数据?
train_x_n=ones(36,2);
train_y_n=ones(36,9);
[tree,leaf] = meshgrid(80:10:200,1:1:10);
bestRMSE_RF = 1;
% 网格搜索
for i=1:size(leaf,1)
for j=1:size(tree,2)
model=TreeBagger(tree(i,j), train_x_n, train_y_n, OOBPredictorImportance=’on’,Method=’regression’, OOBPrediction=’on’,MinLeafSize=leaf(i,j));
[~,~,RMSE,~]=Test(model,train_x_n,train_y,PSo);
if RMSE<bestRMSE_RF
bestRMSE_RF=RMSE;
besttree=tree(i,j);
bestleaf=leaf(i,j);
model_RF=model;
end
end
end train_x_n为36×2double,train_y_n为36×9double,但model=TreeBagger(tree(i,j), train_x_n, train_y_n, ……一行报错“数据类型无效。响应必须为双精度或单精度向量。”(Invalid data type. Response must be a double or single vector.)
当把train_y_n改成36×1时便不报错,请问如何使它能训练多输出数据?
train_x_n=ones(36,2);
train_y_n=ones(36,9);
[tree,leaf] = meshgrid(80:10:200,1:1:10);
bestRMSE_RF = 1;
% 网格搜索
for i=1:size(leaf,1)
for j=1:size(tree,2)
model=TreeBagger(tree(i,j), train_x_n, train_y_n, OOBPredictorImportance=’on’,Method=’regression’, OOBPrediction=’on’,MinLeafSize=leaf(i,j));
[~,~,RMSE,~]=Test(model,train_x_n,train_y,PSo);
if RMSE<bestRMSE_RF
bestRMSE_RF=RMSE;
besttree=tree(i,j);
bestleaf=leaf(i,j);
model_RF=model;
end
end
end machine learning, 机器学习, 多输出, multi-output MATLAB Answers — New Questions
Overlay binary image on RGB image
I would like to overlay the white regions of a binary image onto an RGB image. Is this possible? What about overlaying the black regions?I would like to overlay the white regions of a binary image onto an RGB image. Is this possible? What about overlaying the black regions? I would like to overlay the white regions of a binary image onto an RGB image. Is this possible? What about overlaying the black regions? image processing MATLAB Answers — New Questions
Arduino Uno not working with Simulink (R2024a on macOS)
Folks,
Here’s the scenario:
Arduino Uno + Matlab Arduino Hardware Support + Simulink Arduino Board Support Package, running on macOS Sonoma 14.5, Intel silicone.
All installs well; correct device special file setup during install; hardware tests OK with the Matlab Arduino hardwware support (server uploaded …etc). Simulink: sme think, except that it will just report some unknown function call in the main Matlab window during install, but all goes weel and installs.
Now the fun (or lack thereof ?) beings
Following the basic instructions to get the first LED example working, both starting from a blank model, or using the pre-existing model, said to be for the Mega250.
In the case of starting from a blank model, I’m using the Arduino digital output + a pulse generator, as per the example and screenshot below:
When I come to configure the model, there’s no option, anywhere to select the board and port, let alone to deploy and run it, as shown below:
There’s just the option to download the board support package (which I downloaded and installed), and round, and round, and round we go.
If I use the pre-bundled example, I now get the Atmege250 in the list, but not my Uno (which, yes, I installed and configured earlier …etc):
Can someone tell me what’s going on, and help please?
Thanks in advance,
Ahmed.Folks,
Here’s the scenario:
Arduino Uno + Matlab Arduino Hardware Support + Simulink Arduino Board Support Package, running on macOS Sonoma 14.5, Intel silicone.
All installs well; correct device special file setup during install; hardware tests OK with the Matlab Arduino hardwware support (server uploaded …etc). Simulink: sme think, except that it will just report some unknown function call in the main Matlab window during install, but all goes weel and installs.
Now the fun (or lack thereof ?) beings
Following the basic instructions to get the first LED example working, both starting from a blank model, or using the pre-existing model, said to be for the Mega250.
In the case of starting from a blank model, I’m using the Arduino digital output + a pulse generator, as per the example and screenshot below:
When I come to configure the model, there’s no option, anywhere to select the board and port, let alone to deploy and run it, as shown below:
There’s just the option to download the board support package (which I downloaded and installed), and round, and round, and round we go.
If I use the pre-bundled example, I now get the Atmege250 in the list, but not my Uno (which, yes, I installed and configured earlier …etc):
Can someone tell me what’s going on, and help please?
Thanks in advance,
Ahmed. Folks,
Here’s the scenario:
Arduino Uno + Matlab Arduino Hardware Support + Simulink Arduino Board Support Package, running on macOS Sonoma 14.5, Intel silicone.
All installs well; correct device special file setup during install; hardware tests OK with the Matlab Arduino hardwware support (server uploaded …etc). Simulink: sme think, except that it will just report some unknown function call in the main Matlab window during install, but all goes weel and installs.
Now the fun (or lack thereof ?) beings
Following the basic instructions to get the first LED example working, both starting from a blank model, or using the pre-existing model, said to be for the Mega250.
In the case of starting from a blank model, I’m using the Arduino digital output + a pulse generator, as per the example and screenshot below:
When I come to configure the model, there’s no option, anywhere to select the board and port, let alone to deploy and run it, as shown below:
There’s just the option to download the board support package (which I downloaded and installed), and round, and round, and round we go.
If I use the pre-bundled example, I now get the Atmege250 in the list, but not my Uno (which, yes, I installed and configured earlier …etc):
Can someone tell me what’s going on, and help please?
Thanks in advance,
Ahmed. arduino, simulink, macos MATLAB Answers — New Questions
PDE toolbox and load on nodes
I use the PDE Toolbox to analysis a discrete geometry, and I want to put the force vector on a point. But I can’t define a point through the syntax "loadedVertex". Is there any other option to define the point? thank you!I use the PDE Toolbox to analysis a discrete geometry, and I want to put the force vector on a point. But I can’t define a point through the syntax "loadedVertex". Is there any other option to define the point? thank you! I use the PDE Toolbox to analysis a discrete geometry, and I want to put the force vector on a point. But I can’t define a point through the syntax "loadedVertex". Is there any other option to define the point? thank you! pde, load on nodes MATLAB Answers — New Questions
How to put existing figures in one figure together in case labels are also existing?
I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
Due to the "Class labes", it is difficult.
Thank you,
openfig(‘0001.fig’)
openfig(‘0002.fig’)I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
Due to the "Class labes", it is difficult.
Thank you,
openfig(‘0001.fig’)
openfig(‘0002.fig’) I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
Due to the "Class labes", it is difficult.
Thank you,
openfig(‘0001.fig’)
openfig(‘0002.fig’) tiledlayout MATLAB Answers — New Questions
delete element from vector
Hi everyone
how can I delete element from vector …. for example
a=[1,2,3,4,5]
how can I delete 3 from above vector to be
a=[1,2,4,5]
thank you
majidHi everyone
how can I delete element from vector …. for example
a=[1,2,3,4,5]
how can I delete 3 from above vector to be
a=[1,2,4,5]
thank you
majid Hi everyone
how can I delete element from vector …. for example
a=[1,2,3,4,5]
how can I delete 3 from above vector to be
a=[1,2,4,5]
thank you
majid delete element from vector, cheat sheets MATLAB Answers — New Questions
How to put existing figures in one figure together – Ver2?
I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
I used previous answer by "Voss" as below, but doesn’t work for these figures, in this case, where "Class labels" exist.
Thank you very much,
% open the fig files in two new figures
f1 = openfig(‘0001.fig’,’invisible’);
f2 = openfig(‘0002.fig’,’invisible’);
% get the ConfusionMatrixChart in each figure
cmc1 = f1.Children;
cmc2 = f2.Children;
% alternate way to get the ConfusionMatrixChart in each figure
% cmc1 = findall(f1,’Type’,’ConfusionMatrixChart’);
% cmc2 = findall(f2,’Type’,’ConfusionMatrixChart’);
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,1,2);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% same thing, now with a vertical layout
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,2,1);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% delete the original figures
delete([f1 f2])I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
I used previous answer by "Voss" as below, but doesn’t work for these figures, in this case, where "Class labels" exist.
Thank you very much,
% open the fig files in two new figures
f1 = openfig(‘0001.fig’,’invisible’);
f2 = openfig(‘0002.fig’,’invisible’);
% get the ConfusionMatrixChart in each figure
cmc1 = f1.Children;
cmc2 = f2.Children;
% alternate way to get the ConfusionMatrixChart in each figure
% cmc1 = findall(f1,’Type’,’ConfusionMatrixChart’);
% cmc2 = findall(f2,’Type’,’ConfusionMatrixChart’);
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,1,2);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% same thing, now with a vertical layout
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,2,1);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% delete the original figures
delete([f1 f2]) I have two existing figures (‘0001.fig" and "0002.fig"), and want to put in one figure together vertically.
I used previous answer by "Voss" as below, but doesn’t work for these figures, in this case, where "Class labels" exist.
Thank you very much,
% open the fig files in two new figures
f1 = openfig(‘0001.fig’,’invisible’);
f2 = openfig(‘0002.fig’,’invisible’);
% get the ConfusionMatrixChart in each figure
cmc1 = f1.Children;
cmc2 = f2.Children;
% alternate way to get the ConfusionMatrixChart in each figure
% cmc1 = findall(f1,’Type’,’ConfusionMatrixChart’);
% cmc2 = findall(f2,’Type’,’ConfusionMatrixChart’);
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,1,2);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% same thing, now with a vertical layout
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,2,1);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% delete the original figures
delete([f1 f2]) tiledlayout MATLAB Answers — New Questions
I am very new to MATLAB but I have to deliver an assignment. How do I solve matrix dimension issue in line 10 and 11.
Given the following matrix dimensions
L=39360*39360
y=39360*1
q=1*39360
E= 2.8709
X=39360*39360
T=39360*39360
code
1. dq=L*y;
2. dtr=dq.*q’/E;
3. ql = q * L;
4. ldf = L * y;
5. dt = zeros(39360, 39360);
6. dtr = zeros(39360, 39360);
7. for a = 1:39360
8. for b = 1:39360
9. if X(b, 🙂 ~= 0
10. dt(a,b) = ql(:,a)*ldf(b,:) /X(b,:);
11. dtr(a,b) = (ql(:,a)*ldf(b,:)* T))/(X(b,:)*E);
else
dt(a, b) = 0;
dtr(a, b) = 0;
end
end
endGiven the following matrix dimensions
L=39360*39360
y=39360*1
q=1*39360
E= 2.8709
X=39360*39360
T=39360*39360
code
1. dq=L*y;
2. dtr=dq.*q’/E;
3. ql = q * L;
4. ldf = L * y;
5. dt = zeros(39360, 39360);
6. dtr = zeros(39360, 39360);
7. for a = 1:39360
8. for b = 1:39360
9. if X(b, 🙂 ~= 0
10. dt(a,b) = ql(:,a)*ldf(b,:) /X(b,:);
11. dtr(a,b) = (ql(:,a)*ldf(b,:)* T))/(X(b,:)*E);
else
dt(a, b) = 0;
dtr(a, b) = 0;
end
end
end Given the following matrix dimensions
L=39360*39360
y=39360*1
q=1*39360
E= 2.8709
X=39360*39360
T=39360*39360
code
1. dq=L*y;
2. dtr=dq.*q’/E;
3. ql = q * L;
4. ldf = L * y;
5. dt = zeros(39360, 39360);
6. dtr = zeros(39360, 39360);
7. for a = 1:39360
8. for b = 1:39360
9. if X(b, 🙂 ~= 0
10. dt(a,b) = ql(:,a)*ldf(b,:) /X(b,:);
11. dtr(a,b) = (ql(:,a)*ldf(b,:)* T))/(X(b,:)*E);
else
dt(a, b) = 0;
dtr(a, b) = 0;
end
end
end sensitivity analysis MATLAB Answers — New Questions
ERROR: Error using {} Variable index exceeds table dimensions. How to apply function to all cells/tables?
Hi, I have a fucntion called "edit" which I want to apply to all columns of all tables in all cells in "results_velocity_diff" (see attachment).
I tried it using this code as a test:
% Get the first table from the first cell
first_table = results_velocity_diff{1, 1};
% Initialize a cell array to store the results
results = cell(1, width(first_table));
% Apply edit to each column in the first table
for col = 1:width(first_table)
results{col} = edit(first_table{:, col}, 0, 0, 0);
end
That worked fine. But when I try and apply it to the rest of the columns in the tables of the cells using this code:
% Initialize results_edit to store the results
results_edit = {};
% Iterate through each cell array
for i = 1:numel(results_velocity_diff)
sub_cell_array = results_velocity_diff{i};
% Initialize a new sub cell array for the results
edit_sub_cell_array = {};
% Iterate through each table in the sub cell array
for j = 1:numel(sub_cell_array)
table_data = sub_cell_array{j};
edit_table = table(); % Initialize an empty table to store results
% Iterate through each column in the table
for col = 1:width(table_data)
% Apply the edit function to the current column
edit_result = edit(table_data{:, col}, 0, 0, 0);
% Store the result in the edit table
% Creating a new variable name dynamically
var_name = table_data.Properties.VariableNames{col};
edit_table.(var_name) = edit_result;
end
% Store the table in the sub cell array
edit_sub_cell_array{end+1} = edit_table;
end
% Store the sub cell array in results_edit
results_edit{end+1} = edit_sub_cell_array;
end
Then I get the error:
Error using {}
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one
variable t.(i). To select rows, use t(i,:).
Error in
table_data = sub_cell_array{j};
What am I doing wrong?Hi, I have a fucntion called "edit" which I want to apply to all columns of all tables in all cells in "results_velocity_diff" (see attachment).
I tried it using this code as a test:
% Get the first table from the first cell
first_table = results_velocity_diff{1, 1};
% Initialize a cell array to store the results
results = cell(1, width(first_table));
% Apply edit to each column in the first table
for col = 1:width(first_table)
results{col} = edit(first_table{:, col}, 0, 0, 0);
end
That worked fine. But when I try and apply it to the rest of the columns in the tables of the cells using this code:
% Initialize results_edit to store the results
results_edit = {};
% Iterate through each cell array
for i = 1:numel(results_velocity_diff)
sub_cell_array = results_velocity_diff{i};
% Initialize a new sub cell array for the results
edit_sub_cell_array = {};
% Iterate through each table in the sub cell array
for j = 1:numel(sub_cell_array)
table_data = sub_cell_array{j};
edit_table = table(); % Initialize an empty table to store results
% Iterate through each column in the table
for col = 1:width(table_data)
% Apply the edit function to the current column
edit_result = edit(table_data{:, col}, 0, 0, 0);
% Store the result in the edit table
% Creating a new variable name dynamically
var_name = table_data.Properties.VariableNames{col};
edit_table.(var_name) = edit_result;
end
% Store the table in the sub cell array
edit_sub_cell_array{end+1} = edit_table;
end
% Store the sub cell array in results_edit
results_edit{end+1} = edit_sub_cell_array;
end
Then I get the error:
Error using {}
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one
variable t.(i). To select rows, use t(i,:).
Error in
table_data = sub_cell_array{j};
What am I doing wrong? Hi, I have a fucntion called "edit" which I want to apply to all columns of all tables in all cells in "results_velocity_diff" (see attachment).
I tried it using this code as a test:
% Get the first table from the first cell
first_table = results_velocity_diff{1, 1};
% Initialize a cell array to store the results
results = cell(1, width(first_table));
% Apply edit to each column in the first table
for col = 1:width(first_table)
results{col} = edit(first_table{:, col}, 0, 0, 0);
end
That worked fine. But when I try and apply it to the rest of the columns in the tables of the cells using this code:
% Initialize results_edit to store the results
results_edit = {};
% Iterate through each cell array
for i = 1:numel(results_velocity_diff)
sub_cell_array = results_velocity_diff{i};
% Initialize a new sub cell array for the results
edit_sub_cell_array = {};
% Iterate through each table in the sub cell array
for j = 1:numel(sub_cell_array)
table_data = sub_cell_array{j};
edit_table = table(); % Initialize an empty table to store results
% Iterate through each column in the table
for col = 1:width(table_data)
% Apply the edit function to the current column
edit_result = edit(table_data{:, col}, 0, 0, 0);
% Store the result in the edit table
% Creating a new variable name dynamically
var_name = table_data.Properties.VariableNames{col};
edit_table.(var_name) = edit_result;
end
% Store the table in the sub cell array
edit_sub_cell_array{end+1} = edit_table;
end
% Store the sub cell array in results_edit
results_edit{end+1} = edit_sub_cell_array;
end
Then I get the error:
Error using {}
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one
variable t.(i). To select rows, use t(i,:).
Error in
table_data = sub_cell_array{j};
What am I doing wrong? function, error, subscripting, table MATLAB Answers — New Questions
Add titles over rows in subplots
Hi,
I have a figure with 8 subplots, arranged in two rows. I need to generate an automated code adding a centered title above each row, but fail to do so.
A sample code to illustrate the configuration (I also have annotations):
clf;
m = 2;
n = 4;
p = 1;
for i = 1:m*n
s(i) = subplot(m,n,p);
ant(i) = annotation(‘textbox’,s(i).Position,’String’,[num2str(i)+")"],…
‘linestyle’, ‘none’,’Fontsize’,14,’FontWeight’,’bold’);
p = p + 1;
end
I want to place the titles without explictly give coordinates, i.e. something like titlehandle.position=[1 2 3 4] is not good, because I sometime use different computers/monitors/OS and the output is not consistent.
Thanks!Hi,
I have a figure with 8 subplots, arranged in two rows. I need to generate an automated code adding a centered title above each row, but fail to do so.
A sample code to illustrate the configuration (I also have annotations):
clf;
m = 2;
n = 4;
p = 1;
for i = 1:m*n
s(i) = subplot(m,n,p);
ant(i) = annotation(‘textbox’,s(i).Position,’String’,[num2str(i)+")"],…
‘linestyle’, ‘none’,’Fontsize’,14,’FontWeight’,’bold’);
p = p + 1;
end
I want to place the titles without explictly give coordinates, i.e. something like titlehandle.position=[1 2 3 4] is not good, because I sometime use different computers/monitors/OS and the output is not consistent.
Thanks! Hi,
I have a figure with 8 subplots, arranged in two rows. I need to generate an automated code adding a centered title above each row, but fail to do so.
A sample code to illustrate the configuration (I also have annotations):
clf;
m = 2;
n = 4;
p = 1;
for i = 1:m*n
s(i) = subplot(m,n,p);
ant(i) = annotation(‘textbox’,s(i).Position,’String’,[num2str(i)+")"],…
‘linestyle’, ‘none’,’Fontsize’,14,’FontWeight’,’bold’);
p = p + 1;
end
I want to place the titles without explictly give coordinates, i.e. something like titlehandle.position=[1 2 3 4] is not good, because I sometime use different computers/monitors/OS and the output is not consistent.
Thanks! title, figure, subplot MATLAB Answers — New Questions
Conductive Heat Transfer of Regenerator Block in Gamma Stirling Engine Model
The conductive heat transfer block is set to planar, when i try to change it to cylndrical for more realistic model as the regenerator is in fact cylindrical.
My inputs are as follows:
Inner Diameter = geometry.displacer_piston.radius
Outer Diameter = geometry.displacer_piston.radius + geometry.displacer_piston.glass_thickness
Length = regenerator.geometry.length
Conductivity (K) = regenerator.conductionHeater.k
For both of the conductive blocks, when i do that the engine simply fails to operate.
I used temperature sensors and in original model the temperature between heater and ambient are about 1550 but when i do the cylindrical modification it starts at that difference then decrease to zero as time move on
I want to understand why am i doing wrong.The conductive heat transfer block is set to planar, when i try to change it to cylndrical for more realistic model as the regenerator is in fact cylindrical.
My inputs are as follows:
Inner Diameter = geometry.displacer_piston.radius
Outer Diameter = geometry.displacer_piston.radius + geometry.displacer_piston.glass_thickness
Length = regenerator.geometry.length
Conductivity (K) = regenerator.conductionHeater.k
For both of the conductive blocks, when i do that the engine simply fails to operate.
I used temperature sensors and in original model the temperature between heater and ambient are about 1550 but when i do the cylindrical modification it starts at that difference then decrease to zero as time move on
I want to understand why am i doing wrong. The conductive heat transfer block is set to planar, when i try to change it to cylndrical for more realistic model as the regenerator is in fact cylindrical.
My inputs are as follows:
Inner Diameter = geometry.displacer_piston.radius
Outer Diameter = geometry.displacer_piston.radius + geometry.displacer_piston.glass_thickness
Length = regenerator.geometry.length
Conductivity (K) = regenerator.conductionHeater.k
For both of the conductive blocks, when i do that the engine simply fails to operate.
I used temperature sensors and in original model the temperature between heater and ambient are about 1550 but when i do the cylindrical modification it starts at that difference then decrease to zero as time move on
I want to understand why am i doing wrong. simscape, model MATLAB Answers — New Questions
matrix manipulation for color spaces.
Hi , I have an image . I want to convert that to [3 3] matrix value to play with color space. I understand imead will convert image to matrix form but if I want 3 3 matrix, How should I proceed?Hi , I have an image . I want to convert that to [3 3] matrix value to play with color space. I understand imead will convert image to matrix form but if I want 3 3 matrix, How should I proceed? Hi , I have an image . I want to convert that to [3 3] matrix value to play with color space. I understand imead will convert image to matrix form but if I want 3 3 matrix, How should I proceed? matrix manipulation MATLAB Answers — New Questions
Where is the search bar on the Matlab File Exchange website?
This is more of a recommendation to the MathWorks website developers rather than a quesiton.
I don’t use File Exchange (FEX) often, but when I do, I typically access it through the browser rather than the AddOn button in Matlab. Recently, I noticed that the search bar is missing from FEX, making it impossible to find anything. Upon closer inspection, and five minutes later, I eventually realized that the search option a tiny, barely visible, icon tucked away in the corner of the browser.
To the MathWorks developers responsible for this significant usablity change: why would you hide such a fundamental feature on FEX, which is such a tremendous resource for Matlab users? This change makes it much harder for the users (espicailly those new to Matlab and unfamiliar with FEX) to find what they need and could potentially discourage some from using Matlab.This is more of a recommendation to the MathWorks website developers rather than a quesiton.
I don’t use File Exchange (FEX) often, but when I do, I typically access it through the browser rather than the AddOn button in Matlab. Recently, I noticed that the search bar is missing from FEX, making it impossible to find anything. Upon closer inspection, and five minutes later, I eventually realized that the search option a tiny, barely visible, icon tucked away in the corner of the browser.
To the MathWorks developers responsible for this significant usablity change: why would you hide such a fundamental feature on FEX, which is such a tremendous resource for Matlab users? This change makes it much harder for the users (espicailly those new to Matlab and unfamiliar with FEX) to find what they need and could potentially discourage some from using Matlab. This is more of a recommendation to the MathWorks website developers rather than a quesiton.
I don’t use File Exchange (FEX) often, but when I do, I typically access it through the browser rather than the AddOn button in Matlab. Recently, I noticed that the search bar is missing from FEX, making it impossible to find anything. Upon closer inspection, and five minutes later, I eventually realized that the search option a tiny, barely visible, icon tucked away in the corner of the browser.
To the MathWorks developers responsible for this significant usablity change: why would you hide such a fundamental feature on FEX, which is such a tremendous resource for Matlab users? This change makes it much harder for the users (espicailly those new to Matlab and unfamiliar with FEX) to find what they need and could potentially discourage some from using Matlab. file exchange MATLAB Answers — New Questions
How to detect a data value change in matlab
looking for yur help one more time.
I have data that is constanly hanging, here I share one portion of it
I’m trying to create a variable/falg that helps me to identify when there is a change, somethinng like this:
DATA variable/flag
0 —–> matlab code —–> 0
0 0
0 0
0.1224 1
0.1219 1
0.1199 1
0.1199 0
0.1199 0
0.1175 1
0.1175 0
0.1175 0
0.1175 0
0.1300 1
0.1300 0
0.1200 1
DATA values can change any time, keep same value for different periods of time, and either increase, decrease or change to positive or negative side.
I don’t have much experience with mat lab so any feedback will be highly appreciated.
thankslooking for yur help one more time.
I have data that is constanly hanging, here I share one portion of it
I’m trying to create a variable/falg that helps me to identify when there is a change, somethinng like this:
DATA variable/flag
0 —–> matlab code —–> 0
0 0
0 0
0.1224 1
0.1219 1
0.1199 1
0.1199 0
0.1199 0
0.1175 1
0.1175 0
0.1175 0
0.1175 0
0.1300 1
0.1300 0
0.1200 1
DATA values can change any time, keep same value for different periods of time, and either increase, decrease or change to positive or negative side.
I don’t have much experience with mat lab so any feedback will be highly appreciated.
thanks looking for yur help one more time.
I have data that is constanly hanging, here I share one portion of it
I’m trying to create a variable/falg that helps me to identify when there is a change, somethinng like this:
DATA variable/flag
0 —–> matlab code —–> 0
0 0
0 0
0.1224 1
0.1219 1
0.1199 1
0.1199 0
0.1199 0
0.1175 1
0.1175 0
0.1175 0
0.1175 0
0.1300 1
0.1300 0
0.1200 1
DATA values can change any time, keep same value for different periods of time, and either increase, decrease or change to positive or negative side.
I don’t have much experience with mat lab so any feedback will be highly appreciated.
thanks matlab, data, analysis MATLAB Answers — New Questions
failed Sourcery G++ Lite
Failed to download the third-party software:
Sourcery G++ Lite
This is required by:
Simulink Support Package for Parrot Minidrones
I’m getting this error when installing the mini drone package. I’m using Windows 11. I can’t find a solution. does anyone know the solution?
My Matlab version is R2023BFailed to download the third-party software:
Sourcery G++ Lite
This is required by:
Simulink Support Package for Parrot Minidrones
I’m getting this error when installing the mini drone package. I’m using Windows 11. I can’t find a solution. does anyone know the solution?
My Matlab version is R2023B Failed to download the third-party software:
Sourcery G++ Lite
This is required by:
Simulink Support Package for Parrot Minidrones
I’m getting this error when installing the mini drone package. I’m using Windows 11. I can’t find a solution. does anyone know the solution?
My Matlab version is R2023B mini drone MATLAB Answers — New Questions