Category: Matlab
Category Archives: Matlab
DeepLearning network compiling for embedded code error
I have trained a DL network and save as a .mat file (attached as "Paper3_LSTM_Based_Network2.mat"). The DL network simulates correctly under the Simulink environment (attached as "temp3.slx").
But when I tried to generate the C++ code through Embedded Code, it revealed:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Cannot set ActualArgs property. Number of elements specified does not match number of elements in the Prototype’s Arguments property.
Can someone help me understand this error information? Any solution I can apply with?
Note: The DL network contains the SeqFolding and SeqUnfolding, thus I have to rely on the ARM Compute Library.I have trained a DL network and save as a .mat file (attached as "Paper3_LSTM_Based_Network2.mat"). The DL network simulates correctly under the Simulink environment (attached as "temp3.slx").
But when I tried to generate the C++ code through Embedded Code, it revealed:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Cannot set ActualArgs property. Number of elements specified does not match number of elements in the Prototype’s Arguments property.
Can someone help me understand this error information? Any solution I can apply with?
Note: The DL network contains the SeqFolding and SeqUnfolding, thus I have to rely on the ARM Compute Library. I have trained a DL network and save as a .mat file (attached as "Paper3_LSTM_Based_Network2.mat"). The DL network simulates correctly under the Simulink environment (attached as "temp3.slx").
But when I tried to generate the C++ code through Embedded Code, it revealed:
Internal error while creating code interface description file: codeInfo.mat. Aborting code generation.
Caused by:
Cannot set ActualArgs property. Number of elements specified does not match number of elements in the Prototype’s Arguments property.
Can someone help me understand this error information? Any solution I can apply with?
Note: The DL network contains the SeqFolding and SeqUnfolding, thus I have to rely on the ARM Compute Library. deep learning, embedded coder, simulink MATLAB Answers — New Questions
plot strain ellipse and principal stress axes using eigenvalues and eigevectors.
Hello,
I am trying to plot strain ellipses and principle stress axes (longest and shortest axes of the ellipse) on a grid (x_new,y_new) according to followig instructions. I would be really greatful if someone could help me complete this code.
Thank you.
x = -333.6:5:831.4; %(1×234)
y = 0:5:500; %(1×101)
[xx, yy] = meshgrid(x, y);
dx = 5;
dy = 5;
u = flow values of each grid node in x direction.
v = flow values of each grid node in y direction.
%% Plot Principle axes
pick all the u and v values in rows (45:55) and columns (110:120)
consider four grid nodes at a time. [1 3;2 4]. Then find
% for example
u_2=u(50,116); u_4=u(50,117); %|2 4|%
u_1=u(51,116); u_3=u(51,117); %|1 3|%
v_2=v(50,116); v_4=v(50,117); %|2 4|%
v_1=v(51,116); v_3=v(51,117); %|1 3|%
then using computed ux,uy, vx, vy values, ( e.g. ux=(u1+u2/dx) )
strain_tensor = [ux uy; vx vy];
[V,D]=eig(strain_tensor);
Now I want to use this eigenvalues and eigenvectors to plot strain ellipeses at the center of each four grid nodes along with quiver arrows inside the ellipses.Hello,
I am trying to plot strain ellipses and principle stress axes (longest and shortest axes of the ellipse) on a grid (x_new,y_new) according to followig instructions. I would be really greatful if someone could help me complete this code.
Thank you.
x = -333.6:5:831.4; %(1×234)
y = 0:5:500; %(1×101)
[xx, yy] = meshgrid(x, y);
dx = 5;
dy = 5;
u = flow values of each grid node in x direction.
v = flow values of each grid node in y direction.
%% Plot Principle axes
pick all the u and v values in rows (45:55) and columns (110:120)
consider four grid nodes at a time. [1 3;2 4]. Then find
% for example
u_2=u(50,116); u_4=u(50,117); %|2 4|%
u_1=u(51,116); u_3=u(51,117); %|1 3|%
v_2=v(50,116); v_4=v(50,117); %|2 4|%
v_1=v(51,116); v_3=v(51,117); %|1 3|%
then using computed ux,uy, vx, vy values, ( e.g. ux=(u1+u2/dx) )
strain_tensor = [ux uy; vx vy];
[V,D]=eig(strain_tensor);
Now I want to use this eigenvalues and eigenvectors to plot strain ellipeses at the center of each four grid nodes along with quiver arrows inside the ellipses. Hello,
I am trying to plot strain ellipses and principle stress axes (longest and shortest axes of the ellipse) on a grid (x_new,y_new) according to followig instructions. I would be really greatful if someone could help me complete this code.
Thank you.
x = -333.6:5:831.4; %(1×234)
y = 0:5:500; %(1×101)
[xx, yy] = meshgrid(x, y);
dx = 5;
dy = 5;
u = flow values of each grid node in x direction.
v = flow values of each grid node in y direction.
%% Plot Principle axes
pick all the u and v values in rows (45:55) and columns (110:120)
consider four grid nodes at a time. [1 3;2 4]. Then find
% for example
u_2=u(50,116); u_4=u(50,117); %|2 4|%
u_1=u(51,116); u_3=u(51,117); %|1 3|%
v_2=v(50,116); v_4=v(50,117); %|2 4|%
v_1=v(51,116); v_3=v(51,117); %|1 3|%
then using computed ux,uy, vx, vy values, ( e.g. ux=(u1+u2/dx) )
strain_tensor = [ux uy; vx vy];
[V,D]=eig(strain_tensor);
Now I want to use this eigenvalues and eigenvectors to plot strain ellipeses at the center of each four grid nodes along with quiver arrows inside the ellipses. ellipses, quivers, eigenvalues, eigenvectors MATLAB Answers — New Questions
Using variable in a loop outside the loop
I am getting real time data every 5seconds (with pause) with a loop and the data goes into matrix. How can I use the current data outside the loop and proceed to do computation with the most current data (the first row in the matrix)?
When the loop is running I can not do anything until it is finished.. And I need to create infinite loop to continuously get the data.I am getting real time data every 5seconds (with pause) with a loop and the data goes into matrix. How can I use the current data outside the loop and proceed to do computation with the most current data (the first row in the matrix)?
When the loop is running I can not do anything until it is finished.. And I need to create infinite loop to continuously get the data. I am getting real time data every 5seconds (with pause) with a loop and the data goes into matrix. How can I use the current data outside the loop and proceed to do computation with the most current data (the first row in the matrix)?
When the loop is running I can not do anything until it is finished.. And I need to create infinite loop to continuously get the data. real time data, loops, statistics MATLAB Answers — New Questions
Can I plot a temperature that I scrape (time control set to 5 minutes) off a weather service?
I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6.I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6. I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6. thingspeak MATLAB Answers — New Questions
Can I plot a temperature that I scrape (time control set to 5 minutes) off a weather service?
I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6.I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6. I am copying the example on thingspeak read and write, where I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel. In the example given in thingspeak, Natick MA is used, and I changed that location to my town. Everything works well and I am able to display my local temperature as a widget on my channel, (chart or gage or numeric.) But when I try to plot the temperature, the plot is blank. My data microprocessor for my lab is sending data every 25 seconds or so on 7 fields. (1,2,3,4,5,7,8) The 6th field is the scraped temperature. I can plot any of the other fields. When I do a csv data dump, the data looks like this:
FIELDS— 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc…
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
https://thingspeak.com/channels/2016936
Note: We have not started the boiler yet this season because we have a lot of fire wood we are burning in the fireplace heater.
Thanks. Here is an example of the blank plot for field 6. thingspeak MATLAB Answers — New Questions
When I export results to a text file or csv etc, it is written in only one line, how do I make that it appear in columns?
Hello!
sigma, x, res… are all 10 dimensional vectors that I want them to appear in different columns. When I run the code everything in the txt file is in one line, separated with comas.
T=table(sigma,x,res,dist,k,p);
csvFile = ‘table_data.csv’;
writetable(T, csvFile);Hello!
sigma, x, res… are all 10 dimensional vectors that I want them to appear in different columns. When I run the code everything in the txt file is in one line, separated with comas.
T=table(sigma,x,res,dist,k,p);
csvFile = ‘table_data.csv’;
writetable(T, csvFile); Hello!
sigma, x, res… are all 10 dimensional vectors that I want them to appear in different columns. When I run the code everything in the txt file is in one line, separated with comas.
T=table(sigma,x,res,dist,k,p);
csvFile = ‘table_data.csv’;
writetable(T, csvFile); matlab, txt, csv, one line MATLAB Answers — New Questions
Using the output of one run of a function as the input of another iteration of that function
Hi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
endHi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
end Hi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
end loop MATLAB Answers — New Questions
having a hard time writing a script for a plane truss problem
Im having a hard time writing a code for this problem for school. Any help on how to approach this problem will be much appreciate.Im having a hard time writing a code for this problem for school. Any help on how to approach this problem will be much appreciate. Im having a hard time writing a code for this problem for school. Any help on how to approach this problem will be much appreciate. plane truss MATLAB Answers — New Questions
Newtons Method but error message “Singular Matrix”
When I tried to solve theta and V with Newton for systems I got this error message
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.765187e-24.
Previously I had no problems just solving theta with Newtons for systems, but adding V got me an ill conditioned matrix. We tried different initial values to see if they were triggering, but all of them lead to the same error message. We would be very grateful for any help we could get!
function [theta,V]= newtonfsys1(theta1,V1)
t=1; it=0; maxit=100;theta0=0;V0=200/3.6;
while norm(t)>1e-9 & it<maxit
%Creates a list of x and y values
[v1,v2,v3,v4,v5]=varden(theta0,V0);
[x0,y0]=rungekutta(v1,v2,v3,v4,v5);
[v1,v2,v3,v4,v5]=varden(theta1,V1);
[x1,y1]=rungekutta(v1,v2,v3,v4,v5);
%checking if condition is being met
for i=1:length(x1)
if (abs(11.8872-x1(i))<0.01) && (abs(18.288-x1(end))<0.01)
break
end
end
for p=1:length(x0)
if (abs(11.8872-x0(p))<0.01) && (abs(18.288-x0(end))<0.01)
break
end
end
% takes the "i" & "p" from the condition and picks a good(hopefully constant for x and y
y1=y1(i)-1.001; y0=y0(p)-1.001; x1=x1(i)-11.8872; x0=x0(p)-11.8872;
%approximate derivative
dxdtheta= (x1-x0)/(theta1-theta0);
dydtheta = (y1-y0)/(theta1-theta0);
dxdV = (x1-x0)/(V1-V0);
dydV = (y1-y0)/(V1-V0);
f=[x1;y1];
J = [dxdtheta,dxdV;dydtheta,dydV];
t=Jf;
disp(‘ theta V f t’)
disp([theta1 norm(V1) norm(f) norm(t)])
theta0=theta1; V0=V1; theta1=theta1-t; V1=V1-t(2); it=it+1;
end
if it<maxit
theta=theta1; V=V1;
else
disp(‘Ingen konvergens!’)
theta=[];
endWhen I tried to solve theta and V with Newton for systems I got this error message
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.765187e-24.
Previously I had no problems just solving theta with Newtons for systems, but adding V got me an ill conditioned matrix. We tried different initial values to see if they were triggering, but all of them lead to the same error message. We would be very grateful for any help we could get!
function [theta,V]= newtonfsys1(theta1,V1)
t=1; it=0; maxit=100;theta0=0;V0=200/3.6;
while norm(t)>1e-9 & it<maxit
%Creates a list of x and y values
[v1,v2,v3,v4,v5]=varden(theta0,V0);
[x0,y0]=rungekutta(v1,v2,v3,v4,v5);
[v1,v2,v3,v4,v5]=varden(theta1,V1);
[x1,y1]=rungekutta(v1,v2,v3,v4,v5);
%checking if condition is being met
for i=1:length(x1)
if (abs(11.8872-x1(i))<0.01) && (abs(18.288-x1(end))<0.01)
break
end
end
for p=1:length(x0)
if (abs(11.8872-x0(p))<0.01) && (abs(18.288-x0(end))<0.01)
break
end
end
% takes the "i" & "p" from the condition and picks a good(hopefully constant for x and y
y1=y1(i)-1.001; y0=y0(p)-1.001; x1=x1(i)-11.8872; x0=x0(p)-11.8872;
%approximate derivative
dxdtheta= (x1-x0)/(theta1-theta0);
dydtheta = (y1-y0)/(theta1-theta0);
dxdV = (x1-x0)/(V1-V0);
dydV = (y1-y0)/(V1-V0);
f=[x1;y1];
J = [dxdtheta,dxdV;dydtheta,dydV];
t=Jf;
disp(‘ theta V f t’)
disp([theta1 norm(V1) norm(f) norm(t)])
theta0=theta1; V0=V1; theta1=theta1-t; V1=V1-t(2); it=it+1;
end
if it<maxit
theta=theta1; V=V1;
else
disp(‘Ingen konvergens!’)
theta=[];
end When I tried to solve theta and V with Newton for systems I got this error message
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.765187e-24.
Previously I had no problems just solving theta with Newtons for systems, but adding V got me an ill conditioned matrix. We tried different initial values to see if they were triggering, but all of them lead to the same error message. We would be very grateful for any help we could get!
function [theta,V]= newtonfsys1(theta1,V1)
t=1; it=0; maxit=100;theta0=0;V0=200/3.6;
while norm(t)>1e-9 & it<maxit
%Creates a list of x and y values
[v1,v2,v3,v4,v5]=varden(theta0,V0);
[x0,y0]=rungekutta(v1,v2,v3,v4,v5);
[v1,v2,v3,v4,v5]=varden(theta1,V1);
[x1,y1]=rungekutta(v1,v2,v3,v4,v5);
%checking if condition is being met
for i=1:length(x1)
if (abs(11.8872-x1(i))<0.01) && (abs(18.288-x1(end))<0.01)
break
end
end
for p=1:length(x0)
if (abs(11.8872-x0(p))<0.01) && (abs(18.288-x0(end))<0.01)
break
end
end
% takes the "i" & "p" from the condition and picks a good(hopefully constant for x and y
y1=y1(i)-1.001; y0=y0(p)-1.001; x1=x1(i)-11.8872; x0=x0(p)-11.8872;
%approximate derivative
dxdtheta= (x1-x0)/(theta1-theta0);
dydtheta = (y1-y0)/(theta1-theta0);
dxdV = (x1-x0)/(V1-V0);
dydV = (y1-y0)/(V1-V0);
f=[x1;y1];
J = [dxdtheta,dxdV;dydtheta,dydV];
t=Jf;
disp(‘ theta V f t’)
disp([theta1 norm(V1) norm(f) norm(t)])
theta0=theta1; V0=V1; theta1=theta1-t; V1=V1-t(2); it=it+1;
end
if it<maxit
theta=theta1; V=V1;
else
disp(‘Ingen konvergens!’)
theta=[];
end newton, matrix, singular, system, matlab MATLAB Answers — New Questions
Using the output of one run of a function as the input of another iteration of that function
Hi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
endHi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
end Hi so I’ve a problem where I have made a function that adds neighbouring elements and reduces its size (i.e. 50 elements reduces to 25 after one run of the function). What I want to do is repeat the function until the size of the matrix is 1 so that I can output the final addition. I cannot wrap my head around the loops to use since I want the loop to use the output of the previous iteration as the input for the next iteration i.e. the next run of the same function. For example 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1 elements
I was thinking something like this but it just repeats the first step (50 -> 25 -> 13) a load of times
Thank you for your help
for i = 1:Counter
outputv = ReduceArray(List)
inputv = ReduceArray(outputv);
end loop MATLAB Answers — New Questions
Contourf lines showing up on PDF
I created some contourf plots, set the LevelStep to 1, and removed the lines using LineStyle=’none’. I can copy and paste the figure into PowerPoint and they look great, exactly like I want. But then, when I save the PowerPoint file as a PDF, white lines will appear that look like the contour lines. Is there any way to get it so that they will not show up in the PDF. Attached is the code as well as screenshots from the PPT and the PDF (The black dots are just a scatterplot that I overlaid on the contour plots). Thanks in advance!
[M, c] = contourf(X,Y,Z,’LineStyle’,’none’);
colormap turbo
clim(limits);
c.LevelStep = 1;
xticklabels("");
yticklabels("");
PPT:
PDF:I created some contourf plots, set the LevelStep to 1, and removed the lines using LineStyle=’none’. I can copy and paste the figure into PowerPoint and they look great, exactly like I want. But then, when I save the PowerPoint file as a PDF, white lines will appear that look like the contour lines. Is there any way to get it so that they will not show up in the PDF. Attached is the code as well as screenshots from the PPT and the PDF (The black dots are just a scatterplot that I overlaid on the contour plots). Thanks in advance!
[M, c] = contourf(X,Y,Z,’LineStyle’,’none’);
colormap turbo
clim(limits);
c.LevelStep = 1;
xticklabels("");
yticklabels("");
PPT:
PDF: I created some contourf plots, set the LevelStep to 1, and removed the lines using LineStyle=’none’. I can copy and paste the figure into PowerPoint and they look great, exactly like I want. But then, when I save the PowerPoint file as a PDF, white lines will appear that look like the contour lines. Is there any way to get it so that they will not show up in the PDF. Attached is the code as well as screenshots from the PPT and the PDF (The black dots are just a scatterplot that I overlaid on the contour plots). Thanks in advance!
[M, c] = contourf(X,Y,Z,’LineStyle’,’none’);
colormap turbo
clim(limits);
c.LevelStep = 1;
xticklabels("");
yticklabels("");
PPT:
PDF: contourf MATLAB Answers — New Questions
Differences between Data Acquisition Toolbox and Simulink Real-Time
What are the key differences between Data Acquisition Toolbox, Instrument Control Toolbox, and Simulink Real-time?What are the key differences between Data Acquisition Toolbox, Instrument Control Toolbox, and Simulink Real-time? What are the key differences between Data Acquisition Toolbox, Instrument Control Toolbox, and Simulink Real-time? data acquisition, real-time MATLAB Answers — New Questions
problem after new license
Hello,
Matlab had a notification for updating and new license on 6 December.
After updating and receiving the new license, I could not run a script that I had run before.
I wanted to read txt file and do some calculations.
————-
Array indices must be positive integers or logical values.
Error in untitled (line 21)
fft_out_hdl = sqrt(hexData1.Var1.^2 + hexData3.Var1.^2 + hexData4.Var1.^2)/(2.^32) ;
—————————
I decided to use Matlab online.
My script works fine in Matlab Online, but I had this error in the new updated version.
Please give me suggestion how to solve the error
Thank you for considering this matter.
Best regards
FatemehHello,
Matlab had a notification for updating and new license on 6 December.
After updating and receiving the new license, I could not run a script that I had run before.
I wanted to read txt file and do some calculations.
————-
Array indices must be positive integers or logical values.
Error in untitled (line 21)
fft_out_hdl = sqrt(hexData1.Var1.^2 + hexData3.Var1.^2 + hexData4.Var1.^2)/(2.^32) ;
—————————
I decided to use Matlab online.
My script works fine in Matlab Online, but I had this error in the new updated version.
Please give me suggestion how to solve the error
Thank you for considering this matter.
Best regards
Fatemeh Hello,
Matlab had a notification for updating and new license on 6 December.
After updating and receiving the new license, I could not run a script that I had run before.
I wanted to read txt file and do some calculations.
————-
Array indices must be positive integers or logical values.
Error in untitled (line 21)
fft_out_hdl = sqrt(hexData1.Var1.^2 + hexData3.Var1.^2 + hexData4.Var1.^2)/(2.^32) ;
—————————
I decided to use Matlab online.
My script works fine in Matlab Online, but I had this error in the new updated version.
Please give me suggestion how to solve the error
Thank you for considering this matter.
Best regards
Fatemeh don’t run corrected scripts MATLAB Answers — New Questions
Getting a concatenation error of my matrices when i try and run the program, it ran before and haven’t changed anything since then but today it has refused to cooperate.
It gives me the ‘dimensions of arrays being concatenated are not consistent’ error when I try and run the file. my matrixs are as follows:
A = [0, 1, 0, 0; -k1/ms, -b/ms, k1/ms, b/ms; 0, 0, 0, 1; k1/mus, b/mus, -((k1+k2)/mus), -b/mus]
B = [0, 0; 1/ms, 0; 0, 0; -1/mus, k2/mus]
C = [1, 0, 0, 0]
D = [0, 0]
Any advice would be useful, it ran the other day when I built it and i havent changed anything since it ran last so not sure what the error could beIt gives me the ‘dimensions of arrays being concatenated are not consistent’ error when I try and run the file. my matrixs are as follows:
A = [0, 1, 0, 0; -k1/ms, -b/ms, k1/ms, b/ms; 0, 0, 0, 1; k1/mus, b/mus, -((k1+k2)/mus), -b/mus]
B = [0, 0; 1/ms, 0; 0, 0; -1/mus, k2/mus]
C = [1, 0, 0, 0]
D = [0, 0]
Any advice would be useful, it ran the other day when I built it and i havent changed anything since it ran last so not sure what the error could be It gives me the ‘dimensions of arrays being concatenated are not consistent’ error when I try and run the file. my matrixs are as follows:
A = [0, 1, 0, 0; -k1/ms, -b/ms, k1/ms, b/ms; 0, 0, 0, 1; k1/mus, b/mus, -((k1+k2)/mus), -b/mus]
B = [0, 0; 1/ms, 0; 0, 0; -1/mus, k2/mus]
C = [1, 0, 0, 0]
D = [0, 0]
Any advice would be useful, it ran the other day when I built it and i havent changed anything since it ran last so not sure what the error could be matrix concatenation, state space block MATLAB Answers — New Questions
i wanna animate 2 subplots in the same time and each one for different numbers.
in animation Section
i wanna first subplot to animate until first value of variable Nt_values (541) and the second value of variable Nt_values (361) and the animation of the 2 subplots happen in the same time
Defining Variables
clc,clear;
v = 0.000217; % Kinematic Viscosity
h = 0.04; dy = 0.001; % Y Dimension
Ny = length(linspace(h,0,round(h/dy))) ;
dt_values = [0.002, 0.003]; % Time Dimension
Nt_values = [541 , 361];
% Initial Condition
ic = 0;
% Boundary Conditions
BC_Top = 0;
BC_Bottom = 40;
Solution = cell(1,length(dt_values)) ;
for dt_index = 1:length(dt_values)
dt = dt_values(dt_index);
Nt = Nt_values(dt_index);
% Diffusion Number
d = (v * dt) / (dy^2);
Defining Domain
U = zeros(Ny + 1, Nt);
Initial Condition
U(:, 1) = ic;
Boundary Conditions
U(1, 🙂 = BC_Top;
U(end, 🙂 = BC_Bottom;
Solution
for n = 1:Nt – 1
if n == 1
for j = 2:Ny
U(j, n + 1) = U(j, n) + d * (U(j + 1, n) – 2 * U(j, n) + U(j – 1, n));
end
else
for j = 2:Ny
U(j, n + 1) = (U(j, n – 1) + 2 * d * (U(j + 1, n) – U(j, n – 1) + U(j – 1, n))) / (1 + 2 * d);
end
end
end
Solution{dt_index} = U;
Postprocessing
subplot(length(dt_values), 1,dt_index);
y = linspace(h, 0, round(h / dy) + 1);
Marker = [‘o’, ‘+’, ‘*’, ‘x’, ‘d’, ‘s’, ‘h’];
t_plot = round(linspace(1,Nt,5));
% Initialize legend array >> Just to make Compiling Faster
legend_Values = strings(1, length(t_plot));
for t_plot_i = 1:length(t_plot)
i = t_plot(t_plot_i);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
plot(U(:, i ), y, ‘LineWidth’, 1, "Marker", Marker(t_plot_i));
hold on;
% Put legend Values(String Type) in a cell array
legend_Values{t_plot_i} = [‘at time = ‘ num2str((i-1) * dt)];
end
legend(legend_Values);
end
Animation
figure ;
for an = 1:Nt
subplot(2,1,1);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(1)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(1)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
subplot(2,1,2);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(2)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(2)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
endin animation Section
i wanna first subplot to animate until first value of variable Nt_values (541) and the second value of variable Nt_values (361) and the animation of the 2 subplots happen in the same time
Defining Variables
clc,clear;
v = 0.000217; % Kinematic Viscosity
h = 0.04; dy = 0.001; % Y Dimension
Ny = length(linspace(h,0,round(h/dy))) ;
dt_values = [0.002, 0.003]; % Time Dimension
Nt_values = [541 , 361];
% Initial Condition
ic = 0;
% Boundary Conditions
BC_Top = 0;
BC_Bottom = 40;
Solution = cell(1,length(dt_values)) ;
for dt_index = 1:length(dt_values)
dt = dt_values(dt_index);
Nt = Nt_values(dt_index);
% Diffusion Number
d = (v * dt) / (dy^2);
Defining Domain
U = zeros(Ny + 1, Nt);
Initial Condition
U(:, 1) = ic;
Boundary Conditions
U(1, 🙂 = BC_Top;
U(end, 🙂 = BC_Bottom;
Solution
for n = 1:Nt – 1
if n == 1
for j = 2:Ny
U(j, n + 1) = U(j, n) + d * (U(j + 1, n) – 2 * U(j, n) + U(j – 1, n));
end
else
for j = 2:Ny
U(j, n + 1) = (U(j, n – 1) + 2 * d * (U(j + 1, n) – U(j, n – 1) + U(j – 1, n))) / (1 + 2 * d);
end
end
end
Solution{dt_index} = U;
Postprocessing
subplot(length(dt_values), 1,dt_index);
y = linspace(h, 0, round(h / dy) + 1);
Marker = [‘o’, ‘+’, ‘*’, ‘x’, ‘d’, ‘s’, ‘h’];
t_plot = round(linspace(1,Nt,5));
% Initialize legend array >> Just to make Compiling Faster
legend_Values = strings(1, length(t_plot));
for t_plot_i = 1:length(t_plot)
i = t_plot(t_plot_i);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
plot(U(:, i ), y, ‘LineWidth’, 1, "Marker", Marker(t_plot_i));
hold on;
% Put legend Values(String Type) in a cell array
legend_Values{t_plot_i} = [‘at time = ‘ num2str((i-1) * dt)];
end
legend(legend_Values);
end
Animation
figure ;
for an = 1:Nt
subplot(2,1,1);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(1)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(1)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
subplot(2,1,2);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(2)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(2)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
end in animation Section
i wanna first subplot to animate until first value of variable Nt_values (541) and the second value of variable Nt_values (361) and the animation of the 2 subplots happen in the same time
Defining Variables
clc,clear;
v = 0.000217; % Kinematic Viscosity
h = 0.04; dy = 0.001; % Y Dimension
Ny = length(linspace(h,0,round(h/dy))) ;
dt_values = [0.002, 0.003]; % Time Dimension
Nt_values = [541 , 361];
% Initial Condition
ic = 0;
% Boundary Conditions
BC_Top = 0;
BC_Bottom = 40;
Solution = cell(1,length(dt_values)) ;
for dt_index = 1:length(dt_values)
dt = dt_values(dt_index);
Nt = Nt_values(dt_index);
% Diffusion Number
d = (v * dt) / (dy^2);
Defining Domain
U = zeros(Ny + 1, Nt);
Initial Condition
U(:, 1) = ic;
Boundary Conditions
U(1, 🙂 = BC_Top;
U(end, 🙂 = BC_Bottom;
Solution
for n = 1:Nt – 1
if n == 1
for j = 2:Ny
U(j, n + 1) = U(j, n) + d * (U(j + 1, n) – 2 * U(j, n) + U(j – 1, n));
end
else
for j = 2:Ny
U(j, n + 1) = (U(j, n – 1) + 2 * d * (U(j + 1, n) – U(j, n – 1) + U(j – 1, n))) / (1 + 2 * d);
end
end
end
Solution{dt_index} = U;
Postprocessing
subplot(length(dt_values), 1,dt_index);
y = linspace(h, 0, round(h / dy) + 1);
Marker = [‘o’, ‘+’, ‘*’, ‘x’, ‘d’, ‘s’, ‘h’];
t_plot = round(linspace(1,Nt,5));
% Initialize legend array >> Just to make Compiling Faster
legend_Values = strings(1, length(t_plot));
for t_plot_i = 1:length(t_plot)
i = t_plot(t_plot_i);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
plot(U(:, i ), y, ‘LineWidth’, 1, "Marker", Marker(t_plot_i));
hold on;
% Put legend Values(String Type) in a cell array
legend_Values{t_plot_i} = [‘at time = ‘ num2str((i-1) * dt)];
end
legend(legend_Values);
end
Animation
figure ;
for an = 1:Nt
subplot(2,1,1);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(1)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(1)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
subplot(2,1,2);
plot(U(:, an), y, ‘LineWidth’, 2);
title([‘Velocity Profile Vs. Time at Δt = ‘, num2str(dt_values(2)), ‘ Sec’]);
subtitle([‘Velocity Profile at Time =’, num2str(dt_values(2)*an), ‘ Sec’]);
xlabel(‘Velocity (m/s)’);
ylabel(‘Height (m)’);
drawnow;
end pde, subplot, plot MATLAB Answers — New Questions
Simulink 3D animation and fluid
I want to use Simulink 3D animation to create an instance animation of a single tank control, but I haven’t seen any relevant instructions on fluid animation from the documents and examples. I would like to know if the toolbox can implement this idea and what suggestions are there for a specific solution?I want to use Simulink 3D animation to create an instance animation of a single tank control, but I haven’t seen any relevant instructions on fluid animation from the documents and examples. I would like to know if the toolbox can implement this idea and what suggestions are there for a specific solution? I want to use Simulink 3D animation to create an instance animation of a single tank control, but I haven’t seen any relevant instructions on fluid animation from the documents and examples. I would like to know if the toolbox can implement this idea and what suggestions are there for a specific solution? simulink 3d animation MATLAB Answers — New Questions
how can i get matlab code for this paper
i have paper about ”A_Study_on_Radar_Target_Detection_Based_on_Deep_Neural_Networks" i need the matlab code for dataset creation range doppler radari have paper about ”A_Study_on_Radar_Target_Detection_Based_on_Deep_Neural_Networks" i need the matlab code for dataset creation range doppler radar i have paper about ”A_Study_on_Radar_Target_Detection_Based_on_Deep_Neural_Networks" i need the matlab code for dataset creation range doppler radar radar, range doppler maps, code MATLAB Answers — New Questions
Error evaluating parameter ‘Mass’ , Unable to resolve the name smiData.Solid.
I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issueI am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue error evaluating, mass MATLAB Answers — New Questions
Error evaluating parameter ‘Mass’ , Unable to resolve the name smiData.Solid.
I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issueI am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue I am getting error when i am, importing assembly from the invent. I am having error at the joints and also the parts imported doesn’t import data regarding inertia or geometry. When i run the simulation, I am getting this error
Caused by:
Error evaluating parameter ‘Mass’ in
Unable to resolve the name smiData.Solid.
Error evaluating parameter ‘CenterOfMass’ in ‘NewTestAssembly
Thank you
Sorry i have to hide few names due to some technical issue error evaluating, mass MATLAB Answers — New Questions
Raising errors in Stateflow in accelerated model reference
Okay, so in Stateflow and in Matlab Function blocks, you can cause the smiulation to terminate with an error message by calling the error() function in an action. I have used this from time-to-time to detect fatal conditions that shouldn’t arise, it’s not really for common user errors but more like a failsafe.
The issue is: when the Stateflow is built into an accelerated model reference, the call to error() is just flat-out ignored. (I’d expect no less from The Mathworks than to decide it’s no big deal to just ignore calls to error() without even a warning. It’s not like that error statement was protecting against a buffer overrun or anything, or that it crashed Matlab for no apparent reason, or that we spent a whole day trying to debug the issue. But whatever, that’s not my question.)
We know not to rely on calling error() in Stateflow now, but we need a workaround.
The obvious solution is to have stateflow output a error_status flag, but then how to terminate the simulation with an error message?
Assertion Block is the only way I know of, but we don’t like this block for three reasons: 1. it can be disabled (since we’re protecting against a Matlab crash it’s not really a great idea to be able to disable it), 2.the error message it emits is not useful or customizable, and 3. the input to the assertion is considered a test point with no way to turn it off (so analyst will see all these assertion signals when reviewing data).
The Stop block will terminate the simulation but produces no error message.
I also tried using an S-function (figuring Mathworks can’t ignore errors hand-coded in C, no matter how much they want to), but that has a limitation that the model reference has to be single-instance.
So, any other ideas?Okay, so in Stateflow and in Matlab Function blocks, you can cause the smiulation to terminate with an error message by calling the error() function in an action. I have used this from time-to-time to detect fatal conditions that shouldn’t arise, it’s not really for common user errors but more like a failsafe.
The issue is: when the Stateflow is built into an accelerated model reference, the call to error() is just flat-out ignored. (I’d expect no less from The Mathworks than to decide it’s no big deal to just ignore calls to error() without even a warning. It’s not like that error statement was protecting against a buffer overrun or anything, or that it crashed Matlab for no apparent reason, or that we spent a whole day trying to debug the issue. But whatever, that’s not my question.)
We know not to rely on calling error() in Stateflow now, but we need a workaround.
The obvious solution is to have stateflow output a error_status flag, but then how to terminate the simulation with an error message?
Assertion Block is the only way I know of, but we don’t like this block for three reasons: 1. it can be disabled (since we’re protecting against a Matlab crash it’s not really a great idea to be able to disable it), 2.the error message it emits is not useful or customizable, and 3. the input to the assertion is considered a test point with no way to turn it off (so analyst will see all these assertion signals when reviewing data).
The Stop block will terminate the simulation but produces no error message.
I also tried using an S-function (figuring Mathworks can’t ignore errors hand-coded in C, no matter how much they want to), but that has a limitation that the model reference has to be single-instance.
So, any other ideas? Okay, so in Stateflow and in Matlab Function blocks, you can cause the smiulation to terminate with an error message by calling the error() function in an action. I have used this from time-to-time to detect fatal conditions that shouldn’t arise, it’s not really for common user errors but more like a failsafe.
The issue is: when the Stateflow is built into an accelerated model reference, the call to error() is just flat-out ignored. (I’d expect no less from The Mathworks than to decide it’s no big deal to just ignore calls to error() without even a warning. It’s not like that error statement was protecting against a buffer overrun or anything, or that it crashed Matlab for no apparent reason, or that we spent a whole day trying to debug the issue. But whatever, that’s not my question.)
We know not to rely on calling error() in Stateflow now, but we need a workaround.
The obvious solution is to have stateflow output a error_status flag, but then how to terminate the simulation with an error message?
Assertion Block is the only way I know of, but we don’t like this block for three reasons: 1. it can be disabled (since we’re protecting against a Matlab crash it’s not really a great idea to be able to disable it), 2.the error message it emits is not useful or customizable, and 3. the input to the assertion is considered a test point with no way to turn it off (so analyst will see all these assertion signals when reviewing data).
The Stop block will terminate the simulation but produces no error message.
I also tried using an S-function (figuring Mathworks can’t ignore errors hand-coded in C, no matter how much they want to), but that has a limitation that the model reference has to be single-instance.
So, any other ideas? model reference, accelerator, error MATLAB Answers — New Questions