Tag Archives: matlab
How to display temperature at location x,y in command window for 2D heat transfer
Below is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equalBelow is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equal Below is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equal temperature, location x y MATLAB Answers — New Questions
slow drawing of a set of points on a plane
Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965 Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965 slow drawing of a set of points on a plane MATLAB Answers — New Questions
How to generate random numbers in RL simulation
Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model.Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model. Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model. random number generator, reinforcement learning, simulink MATLAB Answers — New Questions
Is there a setting to move labels on a plot closer
In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots.In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots. In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots. plotting, text, position MATLAB Answers — New Questions
Please help me to run surf plot with bvp4c.
Please help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
endPlease help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
end Please help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
end surf, surface, bvp4c MATLAB Answers — New Questions
Separate data to plot as multiple lines
It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you.It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you. It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you. plot, table MATLAB Answers — New Questions
IVI connection to Rigol DMM
Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’ Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’ ivi, rigol, instrument toolbox MATLAB Answers — New Questions
converting string to num and table
I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance.I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance. I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance. data process MATLAB Answers — New Questions
Can I generate code for STM32H7 Boards using the Embedded Coder Support Package?
Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards?Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards? Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards? embedded, coder, stm32h7, stm32, stmicroelectronics MATLAB Answers — New Questions
plot magnitude data at location (x,y,z)
I can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
JorgeI can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
Jorge I can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
Jorge plotting, 3d plots MATLAB Answers — New Questions
Why do the results returned by calling the “simulate” function with a “creditDefaultCopula” object vary based on the order of the rows in the input data?
When using "creditDefaultCopula" from Risk Management Toolbox, why are simulation results different when the rows of the data input are in different order even with the same random seed for all simulations?When using "creditDefaultCopula" from Risk Management Toolbox, why are simulation results different when the rows of the data input are in different order even with the same random seed for all simulations? When using "creditDefaultCopula" from Risk Management Toolbox, why are simulation results different when the rows of the data input are in different order even with the same random seed for all simulations? creditdefaultcopula, simulation MATLAB Answers — New Questions
Failed Code generation information file doesnt exist.
Post Content Post Content code generation MATLAB Answers — New Questions
I need help on superimposition of plot.
Hi guys, so I took two sets of data of knee extension using two types of sensor which is IMU MPU 6050 and Biopac mechanomyography (MMG), we took it in a same period of time but when it comes to us saving the data, the data we obtain for both plot has different x-axis range. Can anyone please explain and teach me how to do it I would be very appreciate and thank you very muchHi guys, so I took two sets of data of knee extension using two types of sensor which is IMU MPU 6050 and Biopac mechanomyography (MMG), we took it in a same period of time but when it comes to us saving the data, the data we obtain for both plot has different x-axis range. Can anyone please explain and teach me how to do it I would be very appreciate and thank you very much Hi guys, so I took two sets of data of knee extension using two types of sensor which is IMU MPU 6050 and Biopac mechanomyography (MMG), we took it in a same period of time but when it comes to us saving the data, the data we obtain for both plot has different x-axis range. Can anyone please explain and teach me how to do it I would be very appreciate and thank you very much transferred MATLAB Answers — New Questions
What is the difference between the ways of Predict and PredictAndUpdateState to update the network?
Hi All,
I am testing a trained LSTM network to finish the prediction task. I have used prerdict() and PredicAndUpdateState() to do the prediction respectively. The codes for both ways are as follows respectively:
(1). Using predict ()
YTest=predict(trainedNet,XTest); % XTest is the complete test data, which is a numeric array with the size of [16 x 272].
(2). Using PredictAndUpdateState()
for i=1:size(XTest,2)
Xt=XTest(:,i); % One coloum of XTest is extracted as the inputs of this timestep.
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,Xt); % Use the inputs of this timestep to predict the outputs, and update the network.
end
The test performance of using PredictAndUpdateState() is much worse than using predict(). But I have heard that both predict() and PredictAndUpdateState() will update the state of the network between each prediction. So, I wonder why the performances of those two functions are so different, and what is the difference between the ways of predict() and PredictAndUpdateState() to update networks.
Any help will be appredicted. Thank you so much!Hi All,
I am testing a trained LSTM network to finish the prediction task. I have used prerdict() and PredicAndUpdateState() to do the prediction respectively. The codes for both ways are as follows respectively:
(1). Using predict ()
YTest=predict(trainedNet,XTest); % XTest is the complete test data, which is a numeric array with the size of [16 x 272].
(2). Using PredictAndUpdateState()
for i=1:size(XTest,2)
Xt=XTest(:,i); % One coloum of XTest is extracted as the inputs of this timestep.
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,Xt); % Use the inputs of this timestep to predict the outputs, and update the network.
end
The test performance of using PredictAndUpdateState() is much worse than using predict(). But I have heard that both predict() and PredictAndUpdateState() will update the state of the network between each prediction. So, I wonder why the performances of those two functions are so different, and what is the difference between the ways of predict() and PredictAndUpdateState() to update networks.
Any help will be appredicted. Thank you so much! Hi All,
I am testing a trained LSTM network to finish the prediction task. I have used prerdict() and PredicAndUpdateState() to do the prediction respectively. The codes for both ways are as follows respectively:
(1). Using predict ()
YTest=predict(trainedNet,XTest); % XTest is the complete test data, which is a numeric array with the size of [16 x 272].
(2). Using PredictAndUpdateState()
for i=1:size(XTest,2)
Xt=XTest(:,i); % One coloum of XTest is extracted as the inputs of this timestep.
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,Xt); % Use the inputs of this timestep to predict the outputs, and update the network.
end
The test performance of using PredictAndUpdateState() is much worse than using predict(). But I have heard that both predict() and PredictAndUpdateState() will update the state of the network between each prediction. So, I wonder why the performances of those two functions are so different, and what is the difference between the ways of predict() and PredictAndUpdateState() to update networks.
Any help will be appredicted. Thank you so much! lstm, predict, predictandupdatestate, prediction, deep learning MATLAB Answers — New Questions
Issues with looping in structure: variable in the name
I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9)I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9) I am loading one Excel spreadsheet with 11 tabs. The 11 tabs are named fl1, fl2,… fl11.
The spreadsheet is currently loaded into a structure named flight_data. I don’t like the way it is organized, so I want to create a 11 new structures: somename1, somename2,….somename11.
I think the code will show how I’m trying to structure my data. The goal is to have 11 strutures that look like this:
%my loop that doesn’t work
for i = 1:11
fpro(i).loc7.x = flight_data.fpro{i}(:,1)
end
%my structure setup
fpro(i).name = ‘Flight Profile {i}’;
fpro(i).loc7.x = flight_data.fl{i}(:,1)
fpro(i).loc9.x = flight_data.fl{i}(:,4)
fpro(i).loc10.x = flight_data.fl{i}(:,7)
fpro(i).loc7.y = flight_data.fl{i}(:,2)
fpro(i).loc9.y = flight_data.fl{i}(:,5)
fpro(i).loc10.y = flight_data.fl{i}(:,8)
fpro(i).loc7.z = flight_data.fl{i}(:,3)
fpro(i).loc9.z = flight_data.fl{i}(:,6)
fpro(i).loc10.z = flight_data.fl{i}(:,9) for, structures, sytax MATLAB Answers — New Questions
Getting error message when running Runge Kutta solution…
The code that produces the errors is below:
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q – G2*q*r + G3*l + G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q – G1*q*r + G4*l + G8*n), [0 10],0);
plot(t,r,’–b’)
The output with the error messages follows:
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0
0.2500
0.5000
0.7500
1.0000
1.2500
1.5000
1.7500
2.0000
2.2500
2.5000
2.7500
3.0000
3.2500
3.5000
3.7500
4.0000
4.2500
4.5000
4.7500
5.0000
5.2500
5.5000
5.7500
6.0000
6.2500
6.5000
6.7500
7.0000
7.2500
7.5000
7.7500
8.0000
8.2500
8.5000
8.7500
9.0000
9.2500
9.5000
9.7500
10.0000
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To
perform elementwise multiplication, use ‘.*’.
Error in test>@(t,r)(G5*p*r-G6*p*p-G6*r*r+m/Jy) (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in test (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);The code that produces the errors is below:
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q – G2*q*r + G3*l + G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q – G1*q*r + G4*l + G8*n), [0 10],0);
plot(t,r,’–b’)
The output with the error messages follows:
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0
0.2500
0.5000
0.7500
1.0000
1.2500
1.5000
1.7500
2.0000
2.2500
2.5000
2.7500
3.0000
3.2500
3.5000
3.7500
4.0000
4.2500
4.5000
4.7500
5.0000
5.2500
5.5000
5.7500
6.0000
6.2500
6.5000
6.7500
7.0000
7.2500
7.5000
7.7500
8.0000
8.2500
8.5000
8.7500
9.0000
9.2500
9.5000
9.7500
10.0000
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To
perform elementwise multiplication, use ‘.*’.
Error in test>@(t,r)(G5*p*r-G6*p*p-G6*r*r+m/Jy) (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in test (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0); The code that produces the errors is below:
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q – G2*q*r + G3*l + G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q – G1*q*r + G4*l + G8*n), [0 10],0);
plot(t,r,’–b’)
The output with the error messages follows:
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0.1000
0
0.2500
0.5000
0.7500
1.0000
1.2500
1.5000
1.7500
2.0000
2.2500
2.5000
2.7500
3.0000
3.2500
3.5000
3.7500
4.0000
4.2500
4.5000
4.7500
5.0000
5.2500
5.5000
5.7500
6.0000
6.2500
6.5000
6.7500
7.0000
7.2500
7.5000
7.7500
8.0000
8.2500
8.5000
8.7500
9.0000
9.2500
9.5000
9.7500
10.0000
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To
perform elementwise multiplication, use ‘.*’.
Error in test>@(t,r)(G5*p*r-G6*p*p-G6*r*r+m/Jy) (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in test (line 30)
[t,q] = ode45(@(t,r) (G5*p*r – G6*p*p – G6*r*r + m/Jy), [0 10],0); runge kutta 4, errors MATLAB Answers — New Questions
Why does MATLAB crash on Linux with “Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init:”
When I run MATLAB R2021b on my Linux machine, it occasionally crashes. The following error message appears in the terminal or at the top of the resulting crash stack trace:
Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init: Assertion `listp != NULL’ failed!
This crash primarily happens when I attempt to use Simulink for the first time after launching MATLAB.When I run MATLAB R2021b on my Linux machine, it occasionally crashes. The following error message appears in the terminal or at the top of the resulting crash stack trace:
Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init: Assertion `listp != NULL’ failed!
This crash primarily happens when I attempt to use Simulink for the first time after launching MATLAB. When I run MATLAB R2021b on my Linux machine, it occasionally crashes. The following error message appears in the terminal or at the top of the resulting crash stack trace:
Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init: Assertion `listp != NULL’ failed!
This crash primarily happens when I attempt to use Simulink for the first time after launching MATLAB. crash, libc, linux, glibc MATLAB Answers — New Questions
too many open files even after adding fclose within my for loop
As the title says, I am receiving an error saying I have too many open files. I did look into it (via MatlabCentral) and attempted to fix it by adding ‘fclose’ after each ‘fopen.’ I am adding my for loop below. I included the first line of my code (readmatrix), but did not include the lines defining the variables because there are too many. What am I doing wrong here?
Thanks.
m=readmatrix(‘vertebrae_points_idno.xlsx’);
%%did not include lines defining my variables%%
for i=1:length(m)
for j=1:length(m(:,1))
conversion=conversion_array(j);
%combines variables into matrices for saving and printing.
[c1,c2,c3,c4,c5,c6,c7]=matrix_combine(c1x(i,:),c1y(i,:),c2x(i,:),c2y(i,:),c3x(i,:),c3y(i,:),c4x(i,:),c4y(i,:),c5x(i,:),c5y(i,:),c6x(i,:),c6y(i,:),c7x(i,:),c7y(i,:));
%calculate centroids.
[c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid]=get_centroids(c2,c3,c4,c5,c6,c7);
%generate "ideal" arc
[line_x,line_y,x,y,C]=generate_arc(c2,c3,c4,c5,c6,c7);
%transpose for CircleFit
arc_xy=[line_x.’ line_y.’];
%gather points of circle from vertebral points
Par=CircleFit(arc_xy);
%generate actual arc and plot
[x2,y2,true_lord_angle]=generate_second_arc(c2,c7,Par);
%calculate distance between two arcs
[converted_curve_dist,converted_max_curve_dist]=get_curve_distance(x,y,x2,y2,conversion);
%calculates extension angles
[c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(line_x,line_y,c1,c2,c3,c4,c5,c6,c7);
%closes image so the program can create another image with centroids.
close all
%calculates SVA, determines type of kyphosis, plots centroids and C2-C7 centroid line.
[kyphosis_type,sva_axis]=kyphosis_sva_new(c7,c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid, conversion);
spine_data=[converted_curve_dist,converted_max_curve_dist,sva_axis,true_lord_angle,c1_c7_angle,c2_c7_angle];
opening_name=’spine_xray_data.txt’;
opening_name2=’translation_angles.txt’;
fid=fopen(opening_name,’w’);
fprintf(fid,’n %10ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10st %10.4f’,…
sub_id, spine_data,kyphosis_type,conversion);
fclose(fid);
fid2=fopen(opening_name2,’w’);
fprintf(fid2,’n %10.4ft %10.4ft %10.4ft %10.4ft %10.4f’,…
c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent);
fclose(fid2);
end
endAs the title says, I am receiving an error saying I have too many open files. I did look into it (via MatlabCentral) and attempted to fix it by adding ‘fclose’ after each ‘fopen.’ I am adding my for loop below. I included the first line of my code (readmatrix), but did not include the lines defining the variables because there are too many. What am I doing wrong here?
Thanks.
m=readmatrix(‘vertebrae_points_idno.xlsx’);
%%did not include lines defining my variables%%
for i=1:length(m)
for j=1:length(m(:,1))
conversion=conversion_array(j);
%combines variables into matrices for saving and printing.
[c1,c2,c3,c4,c5,c6,c7]=matrix_combine(c1x(i,:),c1y(i,:),c2x(i,:),c2y(i,:),c3x(i,:),c3y(i,:),c4x(i,:),c4y(i,:),c5x(i,:),c5y(i,:),c6x(i,:),c6y(i,:),c7x(i,:),c7y(i,:));
%calculate centroids.
[c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid]=get_centroids(c2,c3,c4,c5,c6,c7);
%generate "ideal" arc
[line_x,line_y,x,y,C]=generate_arc(c2,c3,c4,c5,c6,c7);
%transpose for CircleFit
arc_xy=[line_x.’ line_y.’];
%gather points of circle from vertebral points
Par=CircleFit(arc_xy);
%generate actual arc and plot
[x2,y2,true_lord_angle]=generate_second_arc(c2,c7,Par);
%calculate distance between two arcs
[converted_curve_dist,converted_max_curve_dist]=get_curve_distance(x,y,x2,y2,conversion);
%calculates extension angles
[c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(line_x,line_y,c1,c2,c3,c4,c5,c6,c7);
%closes image so the program can create another image with centroids.
close all
%calculates SVA, determines type of kyphosis, plots centroids and C2-C7 centroid line.
[kyphosis_type,sva_axis]=kyphosis_sva_new(c7,c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid, conversion);
spine_data=[converted_curve_dist,converted_max_curve_dist,sva_axis,true_lord_angle,c1_c7_angle,c2_c7_angle];
opening_name=’spine_xray_data.txt’;
opening_name2=’translation_angles.txt’;
fid=fopen(opening_name,’w’);
fprintf(fid,’n %10ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10st %10.4f’,…
sub_id, spine_data,kyphosis_type,conversion);
fclose(fid);
fid2=fopen(opening_name2,’w’);
fprintf(fid2,’n %10.4ft %10.4ft %10.4ft %10.4ft %10.4f’,…
c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent);
fclose(fid2);
end
end As the title says, I am receiving an error saying I have too many open files. I did look into it (via MatlabCentral) and attempted to fix it by adding ‘fclose’ after each ‘fopen.’ I am adding my for loop below. I included the first line of my code (readmatrix), but did not include the lines defining the variables because there are too many. What am I doing wrong here?
Thanks.
m=readmatrix(‘vertebrae_points_idno.xlsx’);
%%did not include lines defining my variables%%
for i=1:length(m)
for j=1:length(m(:,1))
conversion=conversion_array(j);
%combines variables into matrices for saving and printing.
[c1,c2,c3,c4,c5,c6,c7]=matrix_combine(c1x(i,:),c1y(i,:),c2x(i,:),c2y(i,:),c3x(i,:),c3y(i,:),c4x(i,:),c4y(i,:),c5x(i,:),c5y(i,:),c6x(i,:),c6y(i,:),c7x(i,:),c7y(i,:));
%calculate centroids.
[c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid]=get_centroids(c2,c3,c4,c5,c6,c7);
%generate "ideal" arc
[line_x,line_y,x,y,C]=generate_arc(c2,c3,c4,c5,c6,c7);
%transpose for CircleFit
arc_xy=[line_x.’ line_y.’];
%gather points of circle from vertebral points
Par=CircleFit(arc_xy);
%generate actual arc and plot
[x2,y2,true_lord_angle]=generate_second_arc(c2,c7,Par);
%calculate distance between two arcs
[converted_curve_dist,converted_max_curve_dist]=get_curve_distance(x,y,x2,y2,conversion);
%calculates extension angles
[c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(line_x,line_y,c1,c2,c3,c4,c5,c6,c7);
%closes image so the program can create another image with centroids.
close all
%calculates SVA, determines type of kyphosis, plots centroids and C2-C7 centroid line.
[kyphosis_type,sva_axis]=kyphosis_sva_new(c7,c2_centroid,c3_centroid,c4_centroid,c5_centroid,c6_centroid,c7_centroid, conversion);
spine_data=[converted_curve_dist,converted_max_curve_dist,sva_axis,true_lord_angle,c1_c7_angle,c2_c7_angle];
opening_name=’spine_xray_data.txt’;
opening_name2=’translation_angles.txt’;
fid=fopen(opening_name,’w’);
fprintf(fid,’n %10ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10.2ft %10st %10.4f’,…
sub_id, spine_data,kyphosis_type,conversion);
fclose(fid);
fid2=fopen(opening_name2,’w’);
fprintf(fid2,’n %10.4ft %10.4ft %10.4ft %10.4ft %10.4f’,…
c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent);
fclose(fid2);
end
end error, fclose, fopen MATLAB Answers — New Questions
are there motor resolver models out there?
Has anyone modeled a dc motor and resolver in multibody or other? Looking for an example rather brute force attempting including learning curve.Has anyone modeled a dc motor and resolver in multibody or other? Looking for an example rather brute force attempting including learning curve. Has anyone modeled a dc motor and resolver in multibody or other? Looking for an example rather brute force attempting including learning curve. resolver MATLAB Answers — New Questions
Don’t understand the reason this code is giving me errors.
The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’)The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’) The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’) error in calling runge kutta 4 function. MATLAB Answers — New Questions