Tag Archives: matlab
Please help as I am struggling to solve this homework problem.
An H-section copper conductor carries an overload current of 54000 A. Under steady state conditions, the surface temperature is 60°C.
The dimensions of the bar are given in Figure 1 overleaf, and you are asked to use a numerical method to produce a mesh plot of the temperature distribution and a graph of the temperature distribution along the line y = 0.
The electrical resistivity, ρ, of copper is 2 × 10-8 Ω m, and the thermal conductivity, κ, is 0.311 kW m-1 K-1.
The governing differential equation is ∂2T + ∂2T + g = 0 (1)
∂x2 ∂y2 κ where g is the (constant) generation rate of heat per unit volume:
g = i2ρ (2) and i is the current density.
Using an appropriate Numerical Technique:
Determine the temperature distribution to an accuracy of 4 significant figures
You are expected to hand in the following by the submission date:
Hints
The Gauss-Seidel technique used in Tutorial 9 can be adapted to the present problem by including the additional term g/κ in the finite difference equation. You can generate a mask array as in Tutorial 9 to specify the region of the array covered by the H cross- section.
Try calculating the solution over a square mesh for a range of step lengths h = 5 mm, 2.5 mm, 1.25 mm…
You can if you wish make use of the symmetry of the problem and model just one quarter of the conductor. However, the boundary conditions then become more difficult to apply.
The H section is of width 40mm, depth 30mm and cut outs on top and bottom of depth 10x width 20 mm
Any help would be most appreciated
Cheers
SamAn H-section copper conductor carries an overload current of 54000 A. Under steady state conditions, the surface temperature is 60°C.
The dimensions of the bar are given in Figure 1 overleaf, and you are asked to use a numerical method to produce a mesh plot of the temperature distribution and a graph of the temperature distribution along the line y = 0.
The electrical resistivity, ρ, of copper is 2 × 10-8 Ω m, and the thermal conductivity, κ, is 0.311 kW m-1 K-1.
The governing differential equation is ∂2T + ∂2T + g = 0 (1)
∂x2 ∂y2 κ where g is the (constant) generation rate of heat per unit volume:
g = i2ρ (2) and i is the current density.
Using an appropriate Numerical Technique:
Determine the temperature distribution to an accuracy of 4 significant figures
You are expected to hand in the following by the submission date:
Hints
The Gauss-Seidel technique used in Tutorial 9 can be adapted to the present problem by including the additional term g/κ in the finite difference equation. You can generate a mask array as in Tutorial 9 to specify the region of the array covered by the H cross- section.
Try calculating the solution over a square mesh for a range of step lengths h = 5 mm, 2.5 mm, 1.25 mm…
You can if you wish make use of the symmetry of the problem and model just one quarter of the conductor. However, the boundary conditions then become more difficult to apply.
The H section is of width 40mm, depth 30mm and cut outs on top and bottom of depth 10x width 20 mm
Any help would be most appreciated
Cheers
Sam An H-section copper conductor carries an overload current of 54000 A. Under steady state conditions, the surface temperature is 60°C.
The dimensions of the bar are given in Figure 1 overleaf, and you are asked to use a numerical method to produce a mesh plot of the temperature distribution and a graph of the temperature distribution along the line y = 0.
The electrical resistivity, ρ, of copper is 2 × 10-8 Ω m, and the thermal conductivity, κ, is 0.311 kW m-1 K-1.
The governing differential equation is ∂2T + ∂2T + g = 0 (1)
∂x2 ∂y2 κ where g is the (constant) generation rate of heat per unit volume:
g = i2ρ (2) and i is the current density.
Using an appropriate Numerical Technique:
Determine the temperature distribution to an accuracy of 4 significant figures
You are expected to hand in the following by the submission date:
Hints
The Gauss-Seidel technique used in Tutorial 9 can be adapted to the present problem by including the additional term g/κ in the finite difference equation. You can generate a mask array as in Tutorial 9 to specify the region of the array covered by the H cross- section.
Try calculating the solution over a square mesh for a range of step lengths h = 5 mm, 2.5 mm, 1.25 mm…
You can if you wish make use of the symmetry of the problem and model just one quarter of the conductor. However, the boundary conditions then become more difficult to apply.
The H section is of width 40mm, depth 30mm and cut outs on top and bottom of depth 10x width 20 mm
Any help would be most appreciated
Cheers
Sam differential equations, conductivity, homework, doit4me MATLAB Answers — New Questions
Syms suddenly doesnt work
Something what I have done many times and something that is in matlab helt suddently doesnt work? any idea how that is. Link to matlab help site: https://se.mathworks.com/help/symbolic/syms.html, look under "Create Vector of Symbolic Scalar Variables"
syms c [1 4]
And I get this error:
Warning: deprecated syntax used in sym constructor
> In sym (line 156)
In syms (line 56)
Error using assignin
Invalid variable name "[1 4]" in ASSIGNIN.
Error in syms (line 56)
assignin(‘caller’,varargin{i},sym(varargin{i}));Something what I have done many times and something that is in matlab helt suddently doesnt work? any idea how that is. Link to matlab help site: https://se.mathworks.com/help/symbolic/syms.html, look under "Create Vector of Symbolic Scalar Variables"
syms c [1 4]
And I get this error:
Warning: deprecated syntax used in sym constructor
> In sym (line 156)
In syms (line 56)
Error using assignin
Invalid variable name "[1 4]" in ASSIGNIN.
Error in syms (line 56)
assignin(‘caller’,varargin{i},sym(varargin{i})); Something what I have done many times and something that is in matlab helt suddently doesnt work? any idea how that is. Link to matlab help site: https://se.mathworks.com/help/symbolic/syms.html, look under "Create Vector of Symbolic Scalar Variables"
syms c [1 4]
And I get this error:
Warning: deprecated syntax used in sym constructor
> In sym (line 156)
In syms (line 56)
Error using assignin
Invalid variable name "[1 4]" in ASSIGNIN.
Error in syms (line 56)
assignin(‘caller’,varargin{i},sym(varargin{i})); symbolic MATLAB Answers — New Questions
Matlab live script – symbolic math looks terrible
1st picture is what my matlab live script symbolic math looks like now.
2nd picture is what i want it to look like and what it has looked like earlier.1st picture is what my matlab live script symbolic math looks like now.
2nd picture is what i want it to look like and what it has looked like earlier. 1st picture is what my matlab live script symbolic math looks like now.
2nd picture is what i want it to look like and what it has looked like earlier. matlab live script, live script, symbolic MATLAB Answers — New Questions
how to refactor variable/parameters names used in a whole simulink project
i have a big project (over 20 000 variables) in these variables some are used throughout the entire project in referenced models in certain blocks etc. the variables are mostly enums. i want to change ‘variableA’ to ‘variableB’ how would i do so?
the only thing i got is to change each and every one manualy by hand using a CTRL+F on the main model.
thanks for the help!i have a big project (over 20 000 variables) in these variables some are used throughout the entire project in referenced models in certain blocks etc. the variables are mostly enums. i want to change ‘variableA’ to ‘variableB’ how would i do so?
the only thing i got is to change each and every one manualy by hand using a CTRL+F on the main model.
thanks for the help! i have a big project (over 20 000 variables) in these variables some are used throughout the entire project in referenced models in certain blocks etc. the variables are mostly enums. i want to change ‘variableA’ to ‘variableB’ how would i do so?
the only thing i got is to change each and every one manualy by hand using a CTRL+F on the main model.
thanks for the help! refactor, rename, variable, enum, parameters MATLAB Answers — New Questions
How to load file with variables to each worker in parsim without TransferBaseWorkspaceVariables?
I would like to know how one can load a .mat file (filled with initialization variables) to each worker when using the parsim function (with the Parallel Computing Toolbox). This will be for a local machine with 8 workers. I am using parsim to run a large Monte Carlo analysis of a complex simulink model. This model requires a large set of initialization variables, which slows the total runtime considerably when I manually load the full set of them and use the "TransferBaseWorkspaceVariables" argument of parsim.
I have tried to use the "AttachedFiles" and "SetupFcn" arguments to load my initialization file (called "initVars.mat" and is located in my current work directory), as suggested in the following link: https://imathworks.com/matlab/matlab-how-to-avoid-transferring-all-the-workspace-variables-to-the-workers-when-using-parsim/
My code for the parsim implementation is as follows (with "inPar" being an array of Simulink Input objects):
parsim(inPar,’AttachedFiles’,{‘initVars.mat’},’SetupFcn’,evalin(‘base’,’load initVars.mat’));
I get the following error when trying to run the code:
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
I have tried different forms of the arguments in "evalin", with no success. I have also tried the same arguments with the "PreLoadFcn" modifier to the Input objects, also with no success.
It works when "evalin(‘base’,’load initVars.mat’)" is directly placed into the Simulink Model Properties’ Callbacks tab (into PreLoadFcn). However, I want to do things programmatically as far as possible.
I am using Matlab v2021b Update 3, with Simulink v10.4.
Any help would be appreciated.I would like to know how one can load a .mat file (filled with initialization variables) to each worker when using the parsim function (with the Parallel Computing Toolbox). This will be for a local machine with 8 workers. I am using parsim to run a large Monte Carlo analysis of a complex simulink model. This model requires a large set of initialization variables, which slows the total runtime considerably when I manually load the full set of them and use the "TransferBaseWorkspaceVariables" argument of parsim.
I have tried to use the "AttachedFiles" and "SetupFcn" arguments to load my initialization file (called "initVars.mat" and is located in my current work directory), as suggested in the following link: https://imathworks.com/matlab/matlab-how-to-avoid-transferring-all-the-workspace-variables-to-the-workers-when-using-parsim/
My code for the parsim implementation is as follows (with "inPar" being an array of Simulink Input objects):
parsim(inPar,’AttachedFiles’,{‘initVars.mat’},’SetupFcn’,evalin(‘base’,’load initVars.mat’));
I get the following error when trying to run the code:
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
I have tried different forms of the arguments in "evalin", with no success. I have also tried the same arguments with the "PreLoadFcn" modifier to the Input objects, also with no success.
It works when "evalin(‘base’,’load initVars.mat’)" is directly placed into the Simulink Model Properties’ Callbacks tab (into PreLoadFcn). However, I want to do things programmatically as far as possible.
I am using Matlab v2021b Update 3, with Simulink v10.4.
Any help would be appreciated. I would like to know how one can load a .mat file (filled with initialization variables) to each worker when using the parsim function (with the Parallel Computing Toolbox). This will be for a local machine with 8 workers. I am using parsim to run a large Monte Carlo analysis of a complex simulink model. This model requires a large set of initialization variables, which slows the total runtime considerably when I manually load the full set of them and use the "TransferBaseWorkspaceVariables" argument of parsim.
I have tried to use the "AttachedFiles" and "SetupFcn" arguments to load my initialization file (called "initVars.mat" and is located in my current work directory), as suggested in the following link: https://imathworks.com/matlab/matlab-how-to-avoid-transferring-all-the-workspace-variables-to-the-workers-when-using-parsim/
My code for the parsim implementation is as follows (with "inPar" being an array of Simulink Input objects):
parsim(inPar,’AttachedFiles’,{‘initVars.mat’},’SetupFcn’,evalin(‘base’,’load initVars.mat’));
I get the following error when trying to run the code:
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
I have tried different forms of the arguments in "evalin", with no success. I have also tried the same arguments with the "PreLoadFcn" modifier to the Input objects, also with no success.
It works when "evalin(‘base’,’load initVars.mat’)" is directly placed into the Simulink Model Properties’ Callbacks tab (into PreLoadFcn). However, I want to do things programmatically as far as possible.
I am using Matlab v2021b Update 3, with Simulink v10.4.
Any help would be appreciated. parsim, simulink, parallel computing toolbox, setupfcn, workspace, error MATLAB Answers — New Questions
Values changining after a satellite is initialized.
Hi,
Below is the code which I am using in order to create a satellite scenario. I have defined all the required parameters manually that are required to initialize a satellte, but I am not able to understand why are they getting changed after the satellite is initialized.
startTime = datetime(’27-Jun-2024 13:23:02′);
stopTime = startTime + seconds(60*100);
sampleTime = 10;
sc = satelliteScenario(startTime,stopTime,sampleTime);
mu = 3.986004418*1e14;
n = 15.06398680175205;
semiMajorAxis = nthroot(mu,3)/(((2*n*pi)/86400)^(2/3)) ;
trueAnomaly = 341.2089;
Eccentricity = 1.249e-04;
Inclination = 53.0534;
RightAscensionOfAscendingNode = 242.3386;
ArgumentOfPeriapsis = 94.5842;
sat = satellite(sc,semiMajorAxis,Eccentricity,Inclination,RightAscensionOfAscendingNode,ArgumentOfPeriapsis,trueAnomaly);
elements = orbitalElements(sat);
I would really appreciate if someone can help me figure out why are the values of RAAN and ArgumentOfPeriapsis getting changed after the satellite is initialized.
Thank youHi,
Below is the code which I am using in order to create a satellite scenario. I have defined all the required parameters manually that are required to initialize a satellte, but I am not able to understand why are they getting changed after the satellite is initialized.
startTime = datetime(’27-Jun-2024 13:23:02′);
stopTime = startTime + seconds(60*100);
sampleTime = 10;
sc = satelliteScenario(startTime,stopTime,sampleTime);
mu = 3.986004418*1e14;
n = 15.06398680175205;
semiMajorAxis = nthroot(mu,3)/(((2*n*pi)/86400)^(2/3)) ;
trueAnomaly = 341.2089;
Eccentricity = 1.249e-04;
Inclination = 53.0534;
RightAscensionOfAscendingNode = 242.3386;
ArgumentOfPeriapsis = 94.5842;
sat = satellite(sc,semiMajorAxis,Eccentricity,Inclination,RightAscensionOfAscendingNode,ArgumentOfPeriapsis,trueAnomaly);
elements = orbitalElements(sat);
I would really appreciate if someone can help me figure out why are the values of RAAN and ArgumentOfPeriapsis getting changed after the satellite is initialized.
Thank you Hi,
Below is the code which I am using in order to create a satellite scenario. I have defined all the required parameters manually that are required to initialize a satellte, but I am not able to understand why are they getting changed after the satellite is initialized.
startTime = datetime(’27-Jun-2024 13:23:02′);
stopTime = startTime + seconds(60*100);
sampleTime = 10;
sc = satelliteScenario(startTime,stopTime,sampleTime);
mu = 3.986004418*1e14;
n = 15.06398680175205;
semiMajorAxis = nthroot(mu,3)/(((2*n*pi)/86400)^(2/3)) ;
trueAnomaly = 341.2089;
Eccentricity = 1.249e-04;
Inclination = 53.0534;
RightAscensionOfAscendingNode = 242.3386;
ArgumentOfPeriapsis = 94.5842;
sat = satellite(sc,semiMajorAxis,Eccentricity,Inclination,RightAscensionOfAscendingNode,ArgumentOfPeriapsis,trueAnomaly);
elements = orbitalElements(sat);
I would really appreciate if someone can help me figure out why are the values of RAAN and ArgumentOfPeriapsis getting changed after the satellite is initialized.
Thank you communication, matlab MATLAB Answers — New Questions
How to correct 180-degree phase shift caused by negative feedback loop
I’m in the process of designing a cascaded PI controller by following a tutorial published by MathWork in 2022. By comparing the close-loop response and the open-loop response of the inner loop, i’m noticing a 180-degree phase shift. The tutorial states before working on the outer loop, this phase shift must be corrected. Can someone please explain how i can do that ? Thanks in advance.
Link to the tutorial:Cascade Digital PID Control Design for Power Electronic Converters – MATLAB & Simulink (mathworks.com)I’m in the process of designing a cascaded PI controller by following a tutorial published by MathWork in 2022. By comparing the close-loop response and the open-loop response of the inner loop, i’m noticing a 180-degree phase shift. The tutorial states before working on the outer loop, this phase shift must be corrected. Can someone please explain how i can do that ? Thanks in advance.
Link to the tutorial:Cascade Digital PID Control Design for Power Electronic Converters – MATLAB & Simulink (mathworks.com) I’m in the process of designing a cascaded PI controller by following a tutorial published by MathWork in 2022. By comparing the close-loop response and the open-loop response of the inner loop, i’m noticing a 180-degree phase shift. The tutorial states before working on the outer loop, this phase shift must be corrected. Can someone please explain how i can do that ? Thanks in advance.
Link to the tutorial:Cascade Digital PID Control Design for Power Electronic Converters – MATLAB & Simulink (mathworks.com) control, power_electronics_control MATLAB Answers — New Questions
Figure changes during export
Hello everyone. I have created a loop where my function would save a plot of a series of posterior tangents overlaying vertebrae of the cervical spine. The problem is, after my function runs (code displayed below) only 5 out of the 6 lines appear on the plot. If I run it in isolation in the command window, all 6 lines appear. I have attached the images, the plot pre export with all 6 lines (ran in command window) and post export with the incorrect number (run as a function). I have gone through a number of times and cannot figure out why one line disappears when exporting. Any ideas?
Thanks in advance.
PS I have commented out parts of the code that are not relevant for this question. I did not delete so you were not confused about the input/output variables of my function.
function [c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(c1x,c1y,c2x,c2y,c3x,c3y,c4x,c4y,c5x,c5y,c6x,c6y,c7x,c7y,new_filename,i2)
%define posterior corners.
c2post=[c2x(1) c2y(1); c2x(4) c2y(4)];
c3post=[c3x(1) c3y(1); c3x(4) c3y(4)];
c4post=[c4x(1) c4y(1); c4x(4) c4y(4)];
c5post=[c5x(1) c5y(1); c5x(4) c5y(4)];
c6post=[c6x(1) c6y(1); c6x(4) c6y(4)];
c7post=[c7x(1) c7y(1); c7x(4) c7y(4)];
%c2_angle=rad2deg(atan((c2post(2,2)-c2post(1,2))/(c2post(2,1)-c2post(1,1))));
%c3_angle=rad2deg(atan((c3post(2,2)-c3post(1,2))/(c3post(2,1)-c3post(1,1))));
%c4_angle=rad2deg(atan((c4post(2,2)-c4post(1,2))/(c4post(2,1)-c4post(1,1))));
%c5_angle=rad2deg(atan((c5post(2,2)-c5post(1,2))/(c5post(2,1)-c5post(1,1))));
%c6_angle=rad2deg(atan((c6post(2,2)-c6post(1,2))/(c6post(2,1)-c6post(1,1))));
%c7_angle=rad2deg(atan((c7post(2,2)-c7post(1,2))/(c7post(2,1)-c7post(1,1))));
%c2c3_tangent=c2_angle-c3_angle;
%c3c4_tangent=c3_angle-c4_angle;
%c4c5_tangent=c4_angle-c5_angle;
%c5c6_tangent=c5_angle-c6_angle;
%c6c7_tangent=c6_angle-c7_angle;
%calculate c21-c7 angle by defining angle of inferior vertebral points.
%c1_angle=rad2deg(atan((c1y(1)-c1y(2))/(c1x(2)-c1x(1))));
%c2_inf_ang=rad2deg(atan((c2y(3)-c2y(4))/(c2x(3)-c2x(4))));
%c7_inf_ang=rad2deg(atan((c7y(3)-c7y(4))/(c7x(3)-c7x(4))));
%c1_c7_angle=c7_inf_ang-c1_angle;
%c2_c7_angle=c7_inf_ang-c2_inf_ang;
vertebra_matrix=[c2post;c3post;c4post;c5post;c6post;c7post];
post_x=[c2x(1) c2x(4) c3x(1) c3x(4) c4x(1) c4x(4) c5x(1) c5x(4) c6x(1) c6x(4) c7x(1) c7x(4)];
post_y=[c2y(1) c2y(4) c3y(1) c3y(4) c4y(1) c4y(4) c5y(1) c5y(4) c6y(1) c6y(4) c7y(1) c7y(4)];
theta=zeros([1 6]);
x_diff=zeros([1 6]);
y_diff=zeros([1 6]);
V=zeros([6 2]);
factor_distance=2;
imshow(i2,’InitialMagnification’,100);
hold on;
for h=1:6
f=h*2;
d=f-1;
x_diff(h)=post_x(d)-post_x(f);
y_diff(h)=post_y(f)-post_y(d);
theta(h)=rad2deg(atan(y_diff/x_diff));
V(h,:)=vertebra_matrix(d,:)-vertebra_matrix(f,:);
pext(h,:)=vertebra_matrix(h,:)+V(h,:)*factor_distance;
ax=gca;
output_filename=sprintf(‘%s_rotation.tif’,new_filename);
exportgraphics(ax,output_filename);
plot([post_x(f),pext(h,1)],[post_y(f),pext(h,2)],’r-‘)
end
endHello everyone. I have created a loop where my function would save a plot of a series of posterior tangents overlaying vertebrae of the cervical spine. The problem is, after my function runs (code displayed below) only 5 out of the 6 lines appear on the plot. If I run it in isolation in the command window, all 6 lines appear. I have attached the images, the plot pre export with all 6 lines (ran in command window) and post export with the incorrect number (run as a function). I have gone through a number of times and cannot figure out why one line disappears when exporting. Any ideas?
Thanks in advance.
PS I have commented out parts of the code that are not relevant for this question. I did not delete so you were not confused about the input/output variables of my function.
function [c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(c1x,c1y,c2x,c2y,c3x,c3y,c4x,c4y,c5x,c5y,c6x,c6y,c7x,c7y,new_filename,i2)
%define posterior corners.
c2post=[c2x(1) c2y(1); c2x(4) c2y(4)];
c3post=[c3x(1) c3y(1); c3x(4) c3y(4)];
c4post=[c4x(1) c4y(1); c4x(4) c4y(4)];
c5post=[c5x(1) c5y(1); c5x(4) c5y(4)];
c6post=[c6x(1) c6y(1); c6x(4) c6y(4)];
c7post=[c7x(1) c7y(1); c7x(4) c7y(4)];
%c2_angle=rad2deg(atan((c2post(2,2)-c2post(1,2))/(c2post(2,1)-c2post(1,1))));
%c3_angle=rad2deg(atan((c3post(2,2)-c3post(1,2))/(c3post(2,1)-c3post(1,1))));
%c4_angle=rad2deg(atan((c4post(2,2)-c4post(1,2))/(c4post(2,1)-c4post(1,1))));
%c5_angle=rad2deg(atan((c5post(2,2)-c5post(1,2))/(c5post(2,1)-c5post(1,1))));
%c6_angle=rad2deg(atan((c6post(2,2)-c6post(1,2))/(c6post(2,1)-c6post(1,1))));
%c7_angle=rad2deg(atan((c7post(2,2)-c7post(1,2))/(c7post(2,1)-c7post(1,1))));
%c2c3_tangent=c2_angle-c3_angle;
%c3c4_tangent=c3_angle-c4_angle;
%c4c5_tangent=c4_angle-c5_angle;
%c5c6_tangent=c5_angle-c6_angle;
%c6c7_tangent=c6_angle-c7_angle;
%calculate c21-c7 angle by defining angle of inferior vertebral points.
%c1_angle=rad2deg(atan((c1y(1)-c1y(2))/(c1x(2)-c1x(1))));
%c2_inf_ang=rad2deg(atan((c2y(3)-c2y(4))/(c2x(3)-c2x(4))));
%c7_inf_ang=rad2deg(atan((c7y(3)-c7y(4))/(c7x(3)-c7x(4))));
%c1_c7_angle=c7_inf_ang-c1_angle;
%c2_c7_angle=c7_inf_ang-c2_inf_ang;
vertebra_matrix=[c2post;c3post;c4post;c5post;c6post;c7post];
post_x=[c2x(1) c2x(4) c3x(1) c3x(4) c4x(1) c4x(4) c5x(1) c5x(4) c6x(1) c6x(4) c7x(1) c7x(4)];
post_y=[c2y(1) c2y(4) c3y(1) c3y(4) c4y(1) c4y(4) c5y(1) c5y(4) c6y(1) c6y(4) c7y(1) c7y(4)];
theta=zeros([1 6]);
x_diff=zeros([1 6]);
y_diff=zeros([1 6]);
V=zeros([6 2]);
factor_distance=2;
imshow(i2,’InitialMagnification’,100);
hold on;
for h=1:6
f=h*2;
d=f-1;
x_diff(h)=post_x(d)-post_x(f);
y_diff(h)=post_y(f)-post_y(d);
theta(h)=rad2deg(atan(y_diff/x_diff));
V(h,:)=vertebra_matrix(d,:)-vertebra_matrix(f,:);
pext(h,:)=vertebra_matrix(h,:)+V(h,:)*factor_distance;
ax=gca;
output_filename=sprintf(‘%s_rotation.tif’,new_filename);
exportgraphics(ax,output_filename);
plot([post_x(f),pext(h,1)],[post_y(f),pext(h,2)],’r-‘)
end
end Hello everyone. I have created a loop where my function would save a plot of a series of posterior tangents overlaying vertebrae of the cervical spine. The problem is, after my function runs (code displayed below) only 5 out of the 6 lines appear on the plot. If I run it in isolation in the command window, all 6 lines appear. I have attached the images, the plot pre export with all 6 lines (ran in command window) and post export with the incorrect number (run as a function). I have gone through a number of times and cannot figure out why one line disappears when exporting. Any ideas?
Thanks in advance.
PS I have commented out parts of the code that are not relevant for this question. I did not delete so you were not confused about the input/output variables of my function.
function [c1_c7_angle,c2_c7_angle,c2c3_tangent,c3c4_tangent,c4c5_tangent,c5c6_tangent,c6c7_tangent]=rotation_angles(c1x,c1y,c2x,c2y,c3x,c3y,c4x,c4y,c5x,c5y,c6x,c6y,c7x,c7y,new_filename,i2)
%define posterior corners.
c2post=[c2x(1) c2y(1); c2x(4) c2y(4)];
c3post=[c3x(1) c3y(1); c3x(4) c3y(4)];
c4post=[c4x(1) c4y(1); c4x(4) c4y(4)];
c5post=[c5x(1) c5y(1); c5x(4) c5y(4)];
c6post=[c6x(1) c6y(1); c6x(4) c6y(4)];
c7post=[c7x(1) c7y(1); c7x(4) c7y(4)];
%c2_angle=rad2deg(atan((c2post(2,2)-c2post(1,2))/(c2post(2,1)-c2post(1,1))));
%c3_angle=rad2deg(atan((c3post(2,2)-c3post(1,2))/(c3post(2,1)-c3post(1,1))));
%c4_angle=rad2deg(atan((c4post(2,2)-c4post(1,2))/(c4post(2,1)-c4post(1,1))));
%c5_angle=rad2deg(atan((c5post(2,2)-c5post(1,2))/(c5post(2,1)-c5post(1,1))));
%c6_angle=rad2deg(atan((c6post(2,2)-c6post(1,2))/(c6post(2,1)-c6post(1,1))));
%c7_angle=rad2deg(atan((c7post(2,2)-c7post(1,2))/(c7post(2,1)-c7post(1,1))));
%c2c3_tangent=c2_angle-c3_angle;
%c3c4_tangent=c3_angle-c4_angle;
%c4c5_tangent=c4_angle-c5_angle;
%c5c6_tangent=c5_angle-c6_angle;
%c6c7_tangent=c6_angle-c7_angle;
%calculate c21-c7 angle by defining angle of inferior vertebral points.
%c1_angle=rad2deg(atan((c1y(1)-c1y(2))/(c1x(2)-c1x(1))));
%c2_inf_ang=rad2deg(atan((c2y(3)-c2y(4))/(c2x(3)-c2x(4))));
%c7_inf_ang=rad2deg(atan((c7y(3)-c7y(4))/(c7x(3)-c7x(4))));
%c1_c7_angle=c7_inf_ang-c1_angle;
%c2_c7_angle=c7_inf_ang-c2_inf_ang;
vertebra_matrix=[c2post;c3post;c4post;c5post;c6post;c7post];
post_x=[c2x(1) c2x(4) c3x(1) c3x(4) c4x(1) c4x(4) c5x(1) c5x(4) c6x(1) c6x(4) c7x(1) c7x(4)];
post_y=[c2y(1) c2y(4) c3y(1) c3y(4) c4y(1) c4y(4) c5y(1) c5y(4) c6y(1) c6y(4) c7y(1) c7y(4)];
theta=zeros([1 6]);
x_diff=zeros([1 6]);
y_diff=zeros([1 6]);
V=zeros([6 2]);
factor_distance=2;
imshow(i2,’InitialMagnification’,100);
hold on;
for h=1:6
f=h*2;
d=f-1;
x_diff(h)=post_x(d)-post_x(f);
y_diff(h)=post_y(f)-post_y(d);
theta(h)=rad2deg(atan(y_diff/x_diff));
V(h,:)=vertebra_matrix(d,:)-vertebra_matrix(f,:);
pext(h,:)=vertebra_matrix(h,:)+V(h,:)*factor_distance;
ax=gca;
output_filename=sprintf(‘%s_rotation.tif’,new_filename);
exportgraphics(ax,output_filename);
plot([post_x(f),pext(h,1)],[post_y(f),pext(h,2)],’r-‘)
end
end figure, plot MATLAB Answers — New Questions
How to convert datetime into a number?
I have a table whose first column is a timestamp in the format 08-Jan-2016 05:40:00. How do I convert it into numbers?
Wanted output: 20160108054000.
I know the function yyyymmdd(X) is useful but I also need the time to be added.
Thanks!I have a table whose first column is a timestamp in the format 08-Jan-2016 05:40:00. How do I convert it into numbers?
Wanted output: 20160108054000.
I know the function yyyymmdd(X) is useful but I also need the time to be added.
Thanks! I have a table whose first column is a timestamp in the format 08-Jan-2016 05:40:00. How do I convert it into numbers?
Wanted output: 20160108054000.
I know the function yyyymmdd(X) is useful but I also need the time to be added.
Thanks! datetime, string, char, date, time, convert MATLAB Answers — New Questions
How to correctly calculate three-phase voltage at the PCC parallel point ?
I simulated STATCOM model and found that the calculated voltage at PCC point is not correct with the discrete solver used, how to get the correct voltage? Here is the model file I built.Thanks.I simulated STATCOM model and found that the calculated voltage at PCC point is not correct with the discrete solver used, how to get the correct voltage? Here is the model file I built.Thanks. I simulated STATCOM model and found that the calculated voltage at PCC point is not correct with the discrete solver used, how to get the correct voltage? Here is the model file I built.Thanks. three-phase inverter, static reactive power compensator, power quality MATLAB Answers — New Questions
Python virtual environments with MATLAB
How can I use virtual environments with MATLAB’s Python Interface?How can I use virtual environments with MATLAB’s Python Interface? How can I use virtual environments with MATLAB’s Python Interface? MATLAB Answers — New Questions
How to save a MATLAB Simulink based simulaton with scopes data intact for future viewing?
I have a simulation on MATLAB Simulink. I run the simulation and I can view the results on scopes. I can save the results from scopes as MATLAB figures, etc. I can also save the workspace (full or partial).
What I want to do is that when I close the simulation, and open it again, it should be at the point where I closed it. In other words, I want to run a simulation and save it in such a way whenever I need it, I just need to open that file without the need to run it again. In this way, I do not have to save all the results of the scopes one by one. This will speed up my work. It will also help me to save my hard disk space. Moreover, I will not have to spend time to decide which result is important and which is not. I can just open a pre-run simulation and view my required results.I have a simulation on MATLAB Simulink. I run the simulation and I can view the results on scopes. I can save the results from scopes as MATLAB figures, etc. I can also save the workspace (full or partial).
What I want to do is that when I close the simulation, and open it again, it should be at the point where I closed it. In other words, I want to run a simulation and save it in such a way whenever I need it, I just need to open that file without the need to run it again. In this way, I do not have to save all the results of the scopes one by one. This will speed up my work. It will also help me to save my hard disk space. Moreover, I will not have to spend time to decide which result is important and which is not. I can just open a pre-run simulation and view my required results. I have a simulation on MATLAB Simulink. I run the simulation and I can view the results on scopes. I can save the results from scopes as MATLAB figures, etc. I can also save the workspace (full or partial).
What I want to do is that when I close the simulation, and open it again, it should be at the point where I closed it. In other words, I want to run a simulation and save it in such a way whenever I need it, I just need to open that file without the need to run it again. In this way, I do not have to save all the results of the scopes one by one. This will speed up my work. It will also help me to save my hard disk space. Moreover, I will not have to spend time to decide which result is important and which is not. I can just open a pre-run simulation and view my required results. saving a simulation MATLAB Answers — New Questions
I always got error on modelout after I upgraded to R2023.
I have a problem on modelout when I get my parafac result.
I don’t know what I should do on those error..I have a problem on modelout when I get my parafac result.
I don’t know what I should do on those error.. I have a problem on modelout when I get my parafac result.
I don’t know what I should do on those error.. parafac, modelout, excel, export MATLAB Answers — New Questions
Why are my computer activations missing on my license?
My computer activations have suddenly disappeared on my license. Why are my computer activations missing?My computer activations have suddenly disappeared on my license. Why are my computer activations missing? My computer activations have suddenly disappeared on my license. Why are my computer activations missing? MATLAB Answers — New Questions
Exporting image-generated geometry in matlab to FEA compatible format
Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 – R1) / h * Z + R1;
B = (b1 – b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, ‘EdgeColor’, ‘none’, ‘FaceAlpha’, 0.7); % Superficie lateral
fill3(x1, y1, z1, ‘r’); % Base inferior
fill3(x2, y2, z2, ‘b’); % Base superior
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
zlabel(‘Z (m)’);
title(‘Tronco de Cono con Bases Elípticas’);
axis equal;
grid on;
hold off;Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 – R1) / h * Z + R1;
B = (b1 – b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, ‘EdgeColor’, ‘none’, ‘FaceAlpha’, 0.7); % Superficie lateral
fill3(x1, y1, z1, ‘r’); % Base inferior
fill3(x2, y2, z2, ‘b’); % Base superior
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
zlabel(‘Z (m)’);
title(‘Tronco de Cono con Bases Elípticas’);
axis equal;
grid on;
hold off; Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 – R1) / h * Z + R1;
B = (b1 – b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, ‘EdgeColor’, ‘none’, ‘FaceAlpha’, 0.7); % Superficie lateral
fill3(x1, y1, z1, ‘r’); % Base inferior
fill3(x2, y2, z2, ‘b’); % Base superior
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
zlabel(‘Z (m)’);
title(‘Tronco de Cono con Bases Elípticas’);
axis equal;
grid on;
hold off; matlab, 3d plots, export MATLAB Answers — New Questions
World magnetic model frame of reference??
I am using the world magnetic model function wrldmagm as part of a scrip, but the help page that describes the function provides no information about the reference frame used for the magnetic vector. The simulink block seems to use North-East-Down, would it be safe to assume that the script function does the same?I am using the world magnetic model function wrldmagm as part of a scrip, but the help page that describes the function provides no information about the reference frame used for the magnetic vector. The simulink block seems to use North-East-Down, would it be safe to assume that the script function does the same? I am using the world magnetic model function wrldmagm as part of a scrip, but the help page that describes the function provides no information about the reference frame used for the magnetic vector. The simulink block seems to use North-East-Down, would it be safe to assume that the script function does the same? worldmagneticmodel MATLAB Answers — New Questions
Calling a function with no arguments
Hi All,
In my program , I’m trying to call a function with some input arguments but no outputs as I’m using this function for the purpose of plotting.
How should its syntax look like?
[ ] = function_name( var1,var2,var3) // This line is giving me erorr : Assigning an output to an empty array is not supported.
Please suggest me a way to handle this error.
Thanks in advance!Hi All,
In my program , I’m trying to call a function with some input arguments but no outputs as I’m using this function for the purpose of plotting.
How should its syntax look like?
[ ] = function_name( var1,var2,var3) // This line is giving me erorr : Assigning an output to an empty array is not supported.
Please suggest me a way to handle this error.
Thanks in advance! Hi All,
In my program , I’m trying to call a function with some input arguments but no outputs as I’m using this function for the purpose of plotting.
How should its syntax look like?
[ ] = function_name( var1,var2,var3) // This line is giving me erorr : Assigning an output to an empty array is not supported.
Please suggest me a way to handle this error.
Thanks in advance! function MATLAB Answers — New Questions
Why do I get errors related to Updaters during the Hardware Setup of the “Embedded Coder Support Package for STMicroelectronics STM32 Processors”?
I installed the "Embedded Coder Support Package for STMicroelectronics STM32 Processors", but I am unable to complete the Hardware Setup.
At the "Install STM32Cube Firmware" stage, I click the "Install" button and get error such as the following:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] WebUtils:643 – Updater is busy
[ERROR] HomeAdPanel:114 – Failed to refresh advertisement data
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] MainUpdater:2088 – Updater is busy
Or:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[ERROR] Engine:463 – C:UsersPede.stm32cubemxthirdpartiespdscEmbeddedOffice.I-CUBE-FS-RTOS.1.0.1.pdsc:
PDSC version is not supported
swmgr refresh
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[INFO] CheckServerUpdateThread:115 – End of CheckServer Thread
[INFO] LoadServerUpdatesThread:339 – End of LoadServerUpdate ThreadI installed the "Embedded Coder Support Package for STMicroelectronics STM32 Processors", but I am unable to complete the Hardware Setup.
At the "Install STM32Cube Firmware" stage, I click the "Install" button and get error such as the following:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] WebUtils:643 – Updater is busy
[ERROR] HomeAdPanel:114 – Failed to refresh advertisement data
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] MainUpdater:2088 – Updater is busy
Or:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[ERROR] Engine:463 – C:UsersPede.stm32cubemxthirdpartiespdscEmbeddedOffice.I-CUBE-FS-RTOS.1.0.1.pdsc:
PDSC version is not supported
swmgr refresh
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[INFO] CheckServerUpdateThread:115 – End of CheckServer Thread
[INFO] LoadServerUpdatesThread:339 – End of LoadServerUpdate Thread I installed the "Embedded Coder Support Package for STMicroelectronics STM32 Processors", but I am unable to complete the Hardware Setup.
At the "Install STM32Cube Firmware" stage, I click the "Install" button and get error such as the following:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] WebUtils:643 – Updater is busy
[ERROR] HomeAdPanel:114 – Failed to refresh advertisement data
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] WebUtils:384 – Updater is busy
[ERROR] MainUpdater:2088 – Updater is busy
Or:
[ERROR] AnalyticsContext:980 – The ST intranet updater server is unknown: mcucrossselector.codex.cro.st.com
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[ERROR] Engine:463 – C:UsersPede.stm32cubemxthirdpartiespdscEmbeddedOffice.I-CUBE-FS-RTOS.1.0.1.pdsc:
PDSC version is not supported
swmgr refresh
[ERROR] ServerAccessManage:1058 – Problem during Server Connexion : IO error PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[ERROR] ServerAccessManage:537 – Problem during Server Connexion : : updaters.zip.
[ERROR] ServerAccessManage:1032 – Warning during Server Connexion : Unknown host www.ebuc23.com
[ERROR] ServerAccessManage:537 – Unknown host server name. : updaters.zip.
[INFO] CheckServerUpdateThread:115 – End of CheckServer Thread
[INFO] LoadServerUpdatesThread:339 – End of LoadServerUpdate Thread MATLAB Answers — New Questions
Why I can’t save my data in a .mat when using WebAppServer?
My application is used to take a test to several people.
At each instance, Scores.mat is opened. It contains the structure Scores which stores the scores of the previous participants. The number of participants is retrieved. The new participant takes the test and the new scores are added to the strucure Scores. At the end of the test, the structure Scores is saved in Scores.mat, and so on.
% Load the scores table
load Scores.mat
app.Scores = Scores;
% Increment the participant index
app.idxParticipant = length(app.Scores) + 1;
% (…)
% Save scores (code has been modified for better clarity)
app.Scores(app.idxParticipant).Model(1) = app.EditField.Value;
app.Scores(app.idxParticipant).Model(2) = app.EditField_2.Value;
app.Scores(app.idxParticipant).Model(3) = app.EditField_3.Value;
% (…)
% Save listener scores
Scores = app.Scores;
save(‘Scores.mat’,’Scores’)
Locally, everything runs well, of course. But when I test the Matlab WebApp, the very last step doesn’t work: the structure Scores is not saved in Scores.mat and there is no errors in the logs.
Scores.mat is well embedded in the WebApp as I am able to open it and retrieve the Scores structure. The structure is well updated, I’ve checked it, but I am not able to save the updated structure back into Scores.mat.
I hope someone could help me here. Many thanks!My application is used to take a test to several people.
At each instance, Scores.mat is opened. It contains the structure Scores which stores the scores of the previous participants. The number of participants is retrieved. The new participant takes the test and the new scores are added to the strucure Scores. At the end of the test, the structure Scores is saved in Scores.mat, and so on.
% Load the scores table
load Scores.mat
app.Scores = Scores;
% Increment the participant index
app.idxParticipant = length(app.Scores) + 1;
% (…)
% Save scores (code has been modified for better clarity)
app.Scores(app.idxParticipant).Model(1) = app.EditField.Value;
app.Scores(app.idxParticipant).Model(2) = app.EditField_2.Value;
app.Scores(app.idxParticipant).Model(3) = app.EditField_3.Value;
% (…)
% Save listener scores
Scores = app.Scores;
save(‘Scores.mat’,’Scores’)
Locally, everything runs well, of course. But when I test the Matlab WebApp, the very last step doesn’t work: the structure Scores is not saved in Scores.mat and there is no errors in the logs.
Scores.mat is well embedded in the WebApp as I am able to open it and retrieve the Scores structure. The structure is well updated, I’ve checked it, but I am not able to save the updated structure back into Scores.mat.
I hope someone could help me here. Many thanks! My application is used to take a test to several people.
At each instance, Scores.mat is opened. It contains the structure Scores which stores the scores of the previous participants. The number of participants is retrieved. The new participant takes the test and the new scores are added to the strucure Scores. At the end of the test, the structure Scores is saved in Scores.mat, and so on.
% Load the scores table
load Scores.mat
app.Scores = Scores;
% Increment the participant index
app.idxParticipant = length(app.Scores) + 1;
% (…)
% Save scores (code has been modified for better clarity)
app.Scores(app.idxParticipant).Model(1) = app.EditField.Value;
app.Scores(app.idxParticipant).Model(2) = app.EditField_2.Value;
app.Scores(app.idxParticipant).Model(3) = app.EditField_3.Value;
% (…)
% Save listener scores
Scores = app.Scores;
save(‘Scores.mat’,’Scores’)
Locally, everything runs well, of course. But when I test the Matlab WebApp, the very last step doesn’t work: the structure Scores is not saved in Scores.mat and there is no errors in the logs.
Scores.mat is well embedded in the WebApp as I am able to open it and retrieve the Scores structure. The structure is well updated, I’ve checked it, but I am not able to save the updated structure back into Scores.mat.
I hope someone could help me here. Many thanks! wepappserver MATLAB Answers — New Questions
Why do I receive the error “This email is not linked to a license. Use a different email address…” when I try to launch MATLAB?
Why do I see the following error when I try to launch MATLAB?
This email is not linked to a license.
Use a different email address or go to your MathWorks Account to link a license. After the license is linked, try again.Why do I see the following error when I try to launch MATLAB?
This email is not linked to a license.
Use a different email address or go to your MathWorks Account to link a license. After the license is linked, try again. Why do I see the following error when I try to launch MATLAB?
This email is not linked to a license.
Use a different email address or go to your MathWorks Account to link a license. After the license is linked, try again. MATLAB Answers — New Questions