Category: Matlab
Category Archives: Matlab
Usage of spmd in matlab
Can the spmd parallel structure in MATLAB be used to simulate multiple independent computing nodes that can communicate with each other? That is to simulate each process as a computer.Can the spmd parallel structure in MATLAB be used to simulate multiple independent computing nodes that can communicate with each other? That is to simulate each process as a computer. Can the spmd parallel structure in MATLAB be used to simulate multiple independent computing nodes that can communicate with each other? That is to simulate each process as a computer. spmd, parallel computing MATLAB Answers — New Questions
Time Series Regression and ARMA model
Hi, following question. I have a time series of 12000 lognormally distributed (mu=0 and sigma=0.25) numbers.
R=lognrnd(0,0.25,12000,1)
How do you get a regression model for that data? No function seams to support lognormal distribution. And also, for that set of data how do you decide how many lags the ARMA model need?
Please helpHi, following question. I have a time series of 12000 lognormally distributed (mu=0 and sigma=0.25) numbers.
R=lognrnd(0,0.25,12000,1)
How do you get a regression model for that data? No function seams to support lognormal distribution. And also, for that set of data how do you decide how many lags the ARMA model need?
Please help Hi, following question. I have a time series of 12000 lognormally distributed (mu=0 and sigma=0.25) numbers.
R=lognrnd(0,0.25,12000,1)
How do you get a regression model for that data? No function seams to support lognormal distribution. And also, for that set of data how do you decide how many lags the ARMA model need?
Please help math, university, econometrics, economy, regression, ar, arma, arima MATLAB Answers — New Questions
calculate YoY growth rate
Hi,friend,
price2ret function is able to calculate the growth rate of two adjacent values, if it’s monthly data, it can be viewed as month over month change, can I use this function to calculate year over year change on the same monthly data series? thanksHi,friend,
price2ret function is able to calculate the growth rate of two adjacent values, if it’s monthly data, it can be viewed as month over month change, can I use this function to calculate year over year change on the same monthly data series? thanks Hi,friend,
price2ret function is able to calculate the growth rate of two adjacent values, if it’s monthly data, it can be viewed as month over month change, can I use this function to calculate year over year change on the same monthly data series? thanks mom yoy MATLAB Answers — New Questions
Source code for multi hop LEACH protocol in wireless sensor networks
Source code for multi hop LEACH protocol in wireless sensor networksSource code for multi hop LEACH protocol in wireless sensor networks Source code for multi hop LEACH protocol in wireless sensor networks leach, leach protocol, wsn MATLAB Answers — New Questions
Title for a column of subplots
I want to have a title for each column and row of subplots. I’ve tried using sgtitle but it is not giving me the effect I want. Is there another way to achieve this? I’ve included a simplifed example below of what I want to achieve.I want to have a title for each column and row of subplots. I’ve tried using sgtitle but it is not giving me the effect I want. Is there another way to achieve this? I’ve included a simplifed example below of what I want to achieve. I want to have a title for each column and row of subplots. I’ve tried using sgtitle but it is not giving me the effect I want. Is there another way to achieve this? I’ve included a simplifed example below of what I want to achieve. plot, subplot, sgtitle, format, graph, graphing, plotting MATLAB Answers — New Questions
Outputing 256 characters into stream binary file
Hello!
I am trying to export a txt file from Matlab that contains a 100000 x 11 array of values. Preceding these values, I want a header that has up to 256 characters, with "Unformatted Data Version: 202409251" being the first value. I am confused how to input this, and am worried that it is because of Matlab’s 63 character limit. I am using "writematrix(data, ‘data.txt’)" to export to txt.
What I would like the output txt file to be is below:
Unformatted Data Version: 202409251 , Time= 3.81154488E-18
NrecordsFields 8640
1 3812 1 1 1 1 1.588E-03 -9.583E-06 -9.583E-06 0.000E+00 1
11 3822 1 1 1 1 1.592E-03 -9.583E-06 -9.583E-06 0.000E+00 1
Any help would be appreciated!!Hello!
I am trying to export a txt file from Matlab that contains a 100000 x 11 array of values. Preceding these values, I want a header that has up to 256 characters, with "Unformatted Data Version: 202409251" being the first value. I am confused how to input this, and am worried that it is because of Matlab’s 63 character limit. I am using "writematrix(data, ‘data.txt’)" to export to txt.
What I would like the output txt file to be is below:
Unformatted Data Version: 202409251 , Time= 3.81154488E-18
NrecordsFields 8640
1 3812 1 1 1 1 1.588E-03 -9.583E-06 -9.583E-06 0.000E+00 1
11 3822 1 1 1 1 1.592E-03 -9.583E-06 -9.583E-06 0.000E+00 1
Any help would be appreciated!! Hello!
I am trying to export a txt file from Matlab that contains a 100000 x 11 array of values. Preceding these values, I want a header that has up to 256 characters, with "Unformatted Data Version: 202409251" being the first value. I am confused how to input this, and am worried that it is because of Matlab’s 63 character limit. I am using "writematrix(data, ‘data.txt’)" to export to txt.
What I would like the output txt file to be is below:
Unformatted Data Version: 202409251 , Time= 3.81154488E-18
NrecordsFields 8640
1 3812 1 1 1 1 1.588E-03 -9.583E-06 -9.583E-06 0.000E+00 1
11 3822 1 1 1 1 1.592E-03 -9.583E-06 -9.583E-06 0.000E+00 1
Any help would be appreciated!! 256 characters, stream binary, binary MATLAB Answers — New Questions
Error data corruption
Hi, does anyone knows the reason why a received file (video file) have the full size however cannot playback in the windows media player?It stated..Unknown file error.
Does anyone knows why?Is it due to manipulation of my coding?Hi, does anyone knows the reason why a received file (video file) have the full size however cannot playback in the windows media player?It stated..Unknown file error.
Does anyone knows why?Is it due to manipulation of my coding? Hi, does anyone knows the reason why a received file (video file) have the full size however cannot playback in the windows media player?It stated..Unknown file error.
Does anyone knows why?Is it due to manipulation of my coding? for, data corruption, matlab, preallocation MATLAB Answers — New Questions
FFT Code generation for VxWorks
Is it possible to generate C code for FFT and IFFT (from Simulink) for deployment in VxWorks? Can you please provide documentation on how to doIs it possible to generate C code for FFT and IFFT (from Simulink) for deployment in VxWorks? Can you please provide documentation on how to do Is it possible to generate C code for FFT and IFFT (from Simulink) for deployment in VxWorks? Can you please provide documentation on how to do fft c code generation, ifft, simulink, vxworks MATLAB Answers — New Questions
Is edge detection (e.g., Rising, falling) in State flow supports code generation using embedded coder?
While generating code Error comes as "Error:Error: File: C:Program FilesMATLABR2023brtwctlcpublic_apidiagnostics_api.tlc Line: 39 Column: 10 %exit directive: Simulink Coder Fatal: Custom Data Error: Empty DataObject record"
Please support me to resolve this issue.
Thank YouWhile generating code Error comes as "Error:Error: File: C:Program FilesMATLABR2023brtwctlcpublic_apidiagnostics_api.tlc Line: 39 Column: 10 %exit directive: Simulink Coder Fatal: Custom Data Error: Empty DataObject record"
Please support me to resolve this issue.
Thank You While generating code Error comes as "Error:Error: File: C:Program FilesMATLABR2023brtwctlcpublic_apidiagnostics_api.tlc Line: 39 Column: 10 %exit directive: Simulink Coder Fatal: Custom Data Error: Empty DataObject record"
Please support me to resolve this issue.
Thank You simulink, stateflow, embedded coder MATLAB Answers — New Questions
code folding in live scripts
Is code folding in live scripts possible as in .m?Is code folding in live scripts possible as in .m? Is code folding in live scripts possible as in .m? live script MATLAB Answers — New Questions
Bounding box example with image
Hi,
Can someone give a picture example / link for bounding box for image processing / computer vision?
Regards,Hi,
Can someone give a picture example / link for bounding box for image processing / computer vision?
Regards, Hi,
Can someone give a picture example / link for bounding box for image processing / computer vision?
Regards, image processing, computer vision MATLAB Answers — New Questions
Creating TuningGoals for delay margin and multivariable margin.
I want to use systune to tune gains for my Simulink model, using the slTuner interface. I am trying to set up a non-smooth, multi-objective optimization problem that can be solved by systune. However, I am having a difficult time figuring out how to set up two of the hard constraints.
The optimization problem is stated as follows:
minimize
subject to <
<
>
> 0.3
I think I have the soft constraints and first two hard constraints correctly implemented now, using TuningGoal.Variance. However, I have no idea how to properly set up the last two hard constraints. These are the dynamic margin (generalized delay margin) at and the multivarible module margin of . Where is the complementary sensitivity function and is the sensitivity function.
mdl = "TestVehicleModel";
open_system(mdl);
st0 = slTuner(mdl,"TuneGain");
Softreq1 = TuningGoal.Variance("u1","y1",1);
Softreq2 = TuningGoal.Variance("u2","y1",1);
Softreq3 = TuningGoal.Variance("u1","y2",1);
Softreq4 = TuningGoal.Variance("u2","y2",1);
Hardreq1 = TuningGoal.Variance("u1","y3",0.5);
Hardreq2 = TuningGoal.Variance("u2","y3",0.5);
[st, fSoft, gHard] = systune(st0,[Softreq1,Softreq2,Softreq3,Softreq4],[Hardreq1,Hardreq2]);
Can anyone help me with this? I know that it should be possible, as some researches have done it before in previous versions of MATLAB, probably 2018a.I want to use systune to tune gains for my Simulink model, using the slTuner interface. I am trying to set up a non-smooth, multi-objective optimization problem that can be solved by systune. However, I am having a difficult time figuring out how to set up two of the hard constraints.
The optimization problem is stated as follows:
minimize
subject to <
<
>
> 0.3
I think I have the soft constraints and first two hard constraints correctly implemented now, using TuningGoal.Variance. However, I have no idea how to properly set up the last two hard constraints. These are the dynamic margin (generalized delay margin) at and the multivarible module margin of . Where is the complementary sensitivity function and is the sensitivity function.
mdl = "TestVehicleModel";
open_system(mdl);
st0 = slTuner(mdl,"TuneGain");
Softreq1 = TuningGoal.Variance("u1","y1",1);
Softreq2 = TuningGoal.Variance("u2","y1",1);
Softreq3 = TuningGoal.Variance("u1","y2",1);
Softreq4 = TuningGoal.Variance("u2","y2",1);
Hardreq1 = TuningGoal.Variance("u1","y3",0.5);
Hardreq2 = TuningGoal.Variance("u2","y3",0.5);
[st, fSoft, gHard] = systune(st0,[Softreq1,Softreq2,Softreq3,Softreq4],[Hardreq1,Hardreq2]);
Can anyone help me with this? I know that it should be possible, as some researches have done it before in previous versions of MATLAB, probably 2018a. I want to use systune to tune gains for my Simulink model, using the slTuner interface. I am trying to set up a non-smooth, multi-objective optimization problem that can be solved by systune. However, I am having a difficult time figuring out how to set up two of the hard constraints.
The optimization problem is stated as follows:
minimize
subject to <
<
>
> 0.3
I think I have the soft constraints and first two hard constraints correctly implemented now, using TuningGoal.Variance. However, I have no idea how to properly set up the last two hard constraints. These are the dynamic margin (generalized delay margin) at and the multivarible module margin of . Where is the complementary sensitivity function and is the sensitivity function.
mdl = "TestVehicleModel";
open_system(mdl);
st0 = slTuner(mdl,"TuneGain");
Softreq1 = TuningGoal.Variance("u1","y1",1);
Softreq2 = TuningGoal.Variance("u2","y1",1);
Softreq3 = TuningGoal.Variance("u1","y2",1);
Softreq4 = TuningGoal.Variance("u2","y2",1);
Hardreq1 = TuningGoal.Variance("u1","y3",0.5);
Hardreq2 = TuningGoal.Variance("u2","y3",0.5);
[st, fSoft, gHard] = systune(st0,[Softreq1,Softreq2,Softreq3,Softreq4],[Hardreq1,Hardreq2]);
Can anyone help me with this? I know that it should be possible, as some researches have done it before in previous versions of MATLAB, probably 2018a. sltuner, optimization, non-smooth, multi-objective, systune, tuninggoal, simulink, matlab, hinfinity, margin MATLAB Answers — New Questions
Plot time on x axis for 24 hours duration
How can i plot my data against time on x axis which is 24 hours duration split every two hours.
Sample has been attached here.How can i plot my data against time on x axis which is 24 hours duration split every two hours.
Sample has been attached here. How can i plot my data against time on x axis which is 24 hours duration split every two hours.
Sample has been attached here. plot MATLAB Answers — New Questions
How to connect a Subsystem’s outputPorts (more than 5) to “Bus Creator” programmatically (from scripting)
Hi, Suppose I have Subsystems block which has outputs more than 5.
I have added "Bus Creator" using:
add_block("simulink/Commonly Used Blocks/Bus Creator","testing_bus/Bus Creator")
This is creating Bus in testing_bus model with only 2 input ports. Is there a way to create a "Bus Creator" with number of inputs = Size of Subsystem’s Outputports?
(or)
edit the number of input port of "Bus Creator" so that later using for loop, for connections by:
add_line(‘testing_bus’,’Subsystem/1′,’Bus Creator/1′);Hi, Suppose I have Subsystems block which has outputs more than 5.
I have added "Bus Creator" using:
add_block("simulink/Commonly Used Blocks/Bus Creator","testing_bus/Bus Creator")
This is creating Bus in testing_bus model with only 2 input ports. Is there a way to create a "Bus Creator" with number of inputs = Size of Subsystem’s Outputports?
(or)
edit the number of input port of "Bus Creator" so that later using for loop, for connections by:
add_line(‘testing_bus’,’Subsystem/1′,’Bus Creator/1′); Hi, Suppose I have Subsystems block which has outputs more than 5.
I have added "Bus Creator" using:
add_block("simulink/Commonly Used Blocks/Bus Creator","testing_bus/Bus Creator")
This is creating Bus in testing_bus model with only 2 input ports. Is there a way to create a "Bus Creator" with number of inputs = Size of Subsystem’s Outputports?
(or)
edit the number of input port of "Bus Creator" so that later using for loop, for connections by:
add_line(‘testing_bus’,’Subsystem/1′,’Bus Creator/1′); bus creator, bus, script, simulink MATLAB Answers — New Questions
my code wont display figure
% Parameters
L = 1; % Length of the string
c = 1; % Wave speed
num_segments = 200; % Number of segments
dx = L / num_segments; % Discretization step
dt = 0.005; % Time step
num_steps = 10 / dt; % Number of time steps
% Initial wave parameters
left_wave_length = 0.15 * L;
right_wave_length = 0.25 * L;
% Initialize the wave function
x = 0:dx:L;
u = sin(pi * x / left_wave_length) + sin(2 * pi * x / right_wave_length);
% Time integration
for step = 1:num_steps
% Compute second spatial derivative using finite differences
u_xx = (u(1:end-2) – 2*u(2:end-1) + u(3:end)) / dx^2;
% Update the wave equation using finite differences
u_new = 2*u(2:end-1) – u(2:end-1) + c^2 * dt^2 * u_xx;
% Update boundary conditions
u_new1 = [0, u_new, 0];
% Update the wave function
u = u_new1;
end
% Plot at t = 0
figure;
plot(x, u);
title(‘Wave Equation at t = 0’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]);
% Plot at t = 10 [t]
figure;
plot(x, u);
title(‘Wave Equation at t = 10 [t]’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]);% Parameters
L = 1; % Length of the string
c = 1; % Wave speed
num_segments = 200; % Number of segments
dx = L / num_segments; % Discretization step
dt = 0.005; % Time step
num_steps = 10 / dt; % Number of time steps
% Initial wave parameters
left_wave_length = 0.15 * L;
right_wave_length = 0.25 * L;
% Initialize the wave function
x = 0:dx:L;
u = sin(pi * x / left_wave_length) + sin(2 * pi * x / right_wave_length);
% Time integration
for step = 1:num_steps
% Compute second spatial derivative using finite differences
u_xx = (u(1:end-2) – 2*u(2:end-1) + u(3:end)) / dx^2;
% Update the wave equation using finite differences
u_new = 2*u(2:end-1) – u(2:end-1) + c^2 * dt^2 * u_xx;
% Update boundary conditions
u_new1 = [0, u_new, 0];
% Update the wave function
u = u_new1;
end
% Plot at t = 0
figure;
plot(x, u);
title(‘Wave Equation at t = 0’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]);
% Plot at t = 10 [t]
figure;
plot(x, u);
title(‘Wave Equation at t = 10 [t]’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]); % Parameters
L = 1; % Length of the string
c = 1; % Wave speed
num_segments = 200; % Number of segments
dx = L / num_segments; % Discretization step
dt = 0.005; % Time step
num_steps = 10 / dt; % Number of time steps
% Initial wave parameters
left_wave_length = 0.15 * L;
right_wave_length = 0.25 * L;
% Initialize the wave function
x = 0:dx:L;
u = sin(pi * x / left_wave_length) + sin(2 * pi * x / right_wave_length);
% Time integration
for step = 1:num_steps
% Compute second spatial derivative using finite differences
u_xx = (u(1:end-2) – 2*u(2:end-1) + u(3:end)) / dx^2;
% Update the wave equation using finite differences
u_new = 2*u(2:end-1) – u(2:end-1) + c^2 * dt^2 * u_xx;
% Update boundary conditions
u_new1 = [0, u_new, 0];
% Update the wave function
u = u_new1;
end
% Plot at t = 0
figure;
plot(x, u);
title(‘Wave Equation at t = 0’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]);
% Plot at t = 10 [t]
figure;
plot(x, u);
title(‘Wave Equation at t = 10 [t]’);
xlabel(‘Position [L]’);
ylabel(‘Amplitude’);
xlim([0, L]); matlab MATLAB Answers — New Questions
How do i plot this solutions?
Hello,
I want to plot the theta2 values on the x and presures (P2_ALL) on a plot. It seems my pressures are in symbolic form so Im using fplot to plot. When I do this it gives me an error. Does anyone know how to fix this?
clc; clearvars
format short g
M1 = 3 ;
P1 = 1 ;
theta2 = 1:1:30 ;
gamma = 1.4 ;
phi = 4.8 ;
syms beta2
tantheta2 = tand(theta2 );
x = 2*cotd(beta2)*((M1^2*((sind(beta2)).^2)-1 ));
y = M1^2*(gamma+cosd(2*beta2))+2 ;
eqn2 = x/y ;
b0=1 ;
for ii=1:numel(theta2 )
T = tantheta2(ii );
clearvars result2
syms beta2
result2 = vpasolve(T== eqn2, beta2,b0 );
beta2 = vpa(result2 );
Mn1 = M1*sind(beta2); % Eqn 4.7 from Anderson’s
p2p1 = 1+((2*gamma)/(gamma+1))*(Mn1^2-1); % Eqn 4.9 from Anderson’s
Mn2sq= (Mn1^2+(2/(gamma-1)))/((2*gamma/(gamma-1))*Mn1^2-1);% Eqn 4.10 from Anderson’s
Mn2 = sqrt(Mn2sq );
M2 = Mn2/sind(beta2-theta2(ii ));
P2 = p2p1*P1 ;
P2_ALL{ii}=vpa(P2) ;
end
fplot(theta2,P2_ALL)Hello,
I want to plot the theta2 values on the x and presures (P2_ALL) on a plot. It seems my pressures are in symbolic form so Im using fplot to plot. When I do this it gives me an error. Does anyone know how to fix this?
clc; clearvars
format short g
M1 = 3 ;
P1 = 1 ;
theta2 = 1:1:30 ;
gamma = 1.4 ;
phi = 4.8 ;
syms beta2
tantheta2 = tand(theta2 );
x = 2*cotd(beta2)*((M1^2*((sind(beta2)).^2)-1 ));
y = M1^2*(gamma+cosd(2*beta2))+2 ;
eqn2 = x/y ;
b0=1 ;
for ii=1:numel(theta2 )
T = tantheta2(ii );
clearvars result2
syms beta2
result2 = vpasolve(T== eqn2, beta2,b0 );
beta2 = vpa(result2 );
Mn1 = M1*sind(beta2); % Eqn 4.7 from Anderson’s
p2p1 = 1+((2*gamma)/(gamma+1))*(Mn1^2-1); % Eqn 4.9 from Anderson’s
Mn2sq= (Mn1^2+(2/(gamma-1)))/((2*gamma/(gamma-1))*Mn1^2-1);% Eqn 4.10 from Anderson’s
Mn2 = sqrt(Mn2sq );
M2 = Mn2/sind(beta2-theta2(ii ));
P2 = p2p1*P1 ;
P2_ALL{ii}=vpa(P2) ;
end
fplot(theta2,P2_ALL) Hello,
I want to plot the theta2 values on the x and presures (P2_ALL) on a plot. It seems my pressures are in symbolic form so Im using fplot to plot. When I do this it gives me an error. Does anyone know how to fix this?
clc; clearvars
format short g
M1 = 3 ;
P1 = 1 ;
theta2 = 1:1:30 ;
gamma = 1.4 ;
phi = 4.8 ;
syms beta2
tantheta2 = tand(theta2 );
x = 2*cotd(beta2)*((M1^2*((sind(beta2)).^2)-1 ));
y = M1^2*(gamma+cosd(2*beta2))+2 ;
eqn2 = x/y ;
b0=1 ;
for ii=1:numel(theta2 )
T = tantheta2(ii );
clearvars result2
syms beta2
result2 = vpasolve(T== eqn2, beta2,b0 );
beta2 = vpa(result2 );
Mn1 = M1*sind(beta2); % Eqn 4.7 from Anderson’s
p2p1 = 1+((2*gamma)/(gamma+1))*(Mn1^2-1); % Eqn 4.9 from Anderson’s
Mn2sq= (Mn1^2+(2/(gamma-1)))/((2*gamma/(gamma-1))*Mn1^2-1);% Eqn 4.10 from Anderson’s
Mn2 = sqrt(Mn2sq );
M2 = Mn2/sind(beta2-theta2(ii ));
P2 = p2p1*P1 ;
P2_ALL{ii}=vpa(P2) ;
end
fplot(theta2,P2_ALL) fplot, solutions, ploting MATLAB Answers — New Questions
How to create an LC parametric attenuation circuit in simulink.
The terminals are LC only, L=0.1H and C=0.25F with an initial voltage of 1V. The variable capacitor has an initial capacitance of 0.25F and is increased by 0.25F each time the voltage takes an extreme value. The judgment of the extreme value is made by the derivative block, which outputs an impulse signal when hitcrossing becomes 0. Q=CV, and since Q is conserved, C is increased so that V is attenuated.The circuit I am currently working on is as follows, but it does not work well.
The ideal graph is as follows.The terminals are LC only, L=0.1H and C=0.25F with an initial voltage of 1V. The variable capacitor has an initial capacitance of 0.25F and is increased by 0.25F each time the voltage takes an extreme value. The judgment of the extreme value is made by the derivative block, which outputs an impulse signal when hitcrossing becomes 0. Q=CV, and since Q is conserved, C is increased so that V is attenuated.The circuit I am currently working on is as follows, but it does not work well.
The ideal graph is as follows. The terminals are LC only, L=0.1H and C=0.25F with an initial voltage of 1V. The variable capacitor has an initial capacitance of 0.25F and is increased by 0.25F each time the voltage takes an extreme value. The judgment of the extreme value is made by the derivative block, which outputs an impulse signal when hitcrossing becomes 0. Q=CV, and since Q is conserved, C is increased so that V is attenuated.The circuit I am currently working on is as follows, but it does not work well.
The ideal graph is as follows. simulink, variable capacitor, lc MATLAB Answers — New Questions
How to save the graph obtained with Simulink’s scope as numerical data
I have plotted voltage and current using the scope. I want to save the waveforms as a table of time and voltage values with a sampling time of 0.001 seconds.I have plotted voltage and current using the scope. I want to save the waveforms as a table of time and voltage values with a sampling time of 0.001 seconds. I have plotted voltage and current using the scope. I want to save the waveforms as a table of time and voltage values with a sampling time of 0.001 seconds. simulink MATLAB Answers — New Questions
How to effectively solve the problem of incompatibility of AppDesigner using symbol toolkit syms after packaging and publishing into exe and other executable files?
%How to effectively solve the problem of incompatibility of AppDesigner using symbol toolkit syms after packaging and publishing into exe and other executable files? And how can I change it in my code
cla(app.UIAxes)
P=app.PEditField.Value
P=P.*pi/180;
c=app.CKPaEditField.Value;
K=app.KEditField.Value;%侧压力系数
P_ya=app.P_yaEditField.Value;
F=app.FEditField.Value;
y=app.yKNm3EditField.Value;
R = app.RmEditField.Value;
L=app.LmEditField.Value;
L_s=app.L_smEditField.Value;
syms pha H
term1 = 9 – 12 * (1 – P_ya .* F ./ (y .* H));
term2 = R .* sqrt(term1) – 3 .* R;
denominator = 2 .* H;
% 计算 pha
pha = atan(term2 ./ denominator);
% 显示结果
% disp(pha);
pha_rad=rad2deg(pha);
H_vals = linspace(50, 250, 50);
pha_vals = double(subs(pha_rad, H, H_vals));
% Plot H versus pha
% figure(1);
plot(app.UIAxes,H_vals, pha_vals, ‘b-‘, ‘LineWidth’, 2);
xlabel(app.UIAxes,’H’);
ylabel(app.UIAxes,’pha’);
title(app.UIAxes,’Plot of pha vs H’);
% grid on;
% disp(pha_rad);
%修正破裂角计算
if K <= 1
pha_rad = 45 – P / 2;
elseif K <= 2
pha_rad = 45;
else
pha_rad = 45 + P / 2;
end
% 限制 pha_rad 的值在 15° 和 65° 之间
pha_rad = max(15, min(pha_rad, 65));
pha_rad = pha_rad * (pi / 180);
switch app.DropDown.Value
case ‘竖直滑面法’
if app.Button_2.Value==1
Vc2=4.*pi.*R.^3+pi.*R.^2*(L-2.*R);%体积
Ac2=pi.*R.^2+(L-2.*R).*2.*R;
Lc2=2*pi.*R+(L-2*R).*2;%周长
sigma2=Lc2.*H.*K.*y.*H./2;
Fbc2=Vc2.*10;%
Fbr2=Ac2.*10.*(H-L_s);
F2=Ac2.*P_ya;
Wr2=y.*H.*Ac2;%
t2=Lc2.*c.*H+sigma2.*tan(P)
eq=Wr2+t2==F.*(F2+Fbc2+Fbr2)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
elseif app.Button.Value==1
Vc1=4.*pi.*R.^3;%体积
Ac1=pi.*R.^2;%表面积
Lc1=2*pi.*R;%周长
sigma1=Lc1.*H.*K.*y.*H./2;%水平应力和∑σh
Fbc1=Vc1.*10;%硐室浮力
Fbr1=Ac1.*10.*(H-L_s);%岩体浮力
F1=Ac1.*P_ya;%上抬力
Wr1=y.*H.*Ac1;%重量
t1=Lc1.*c.*H+sigma1.*tan(P)
eq=Wr1+t1==F.*(F1+Fbc1+Fbr1)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
end%How to effectively solve the problem of incompatibility of AppDesigner using symbol toolkit syms after packaging and publishing into exe and other executable files? And how can I change it in my code
cla(app.UIAxes)
P=app.PEditField.Value
P=P.*pi/180;
c=app.CKPaEditField.Value;
K=app.KEditField.Value;%侧压力系数
P_ya=app.P_yaEditField.Value;
F=app.FEditField.Value;
y=app.yKNm3EditField.Value;
R = app.RmEditField.Value;
L=app.LmEditField.Value;
L_s=app.L_smEditField.Value;
syms pha H
term1 = 9 – 12 * (1 – P_ya .* F ./ (y .* H));
term2 = R .* sqrt(term1) – 3 .* R;
denominator = 2 .* H;
% 计算 pha
pha = atan(term2 ./ denominator);
% 显示结果
% disp(pha);
pha_rad=rad2deg(pha);
H_vals = linspace(50, 250, 50);
pha_vals = double(subs(pha_rad, H, H_vals));
% Plot H versus pha
% figure(1);
plot(app.UIAxes,H_vals, pha_vals, ‘b-‘, ‘LineWidth’, 2);
xlabel(app.UIAxes,’H’);
ylabel(app.UIAxes,’pha’);
title(app.UIAxes,’Plot of pha vs H’);
% grid on;
% disp(pha_rad);
%修正破裂角计算
if K <= 1
pha_rad = 45 – P / 2;
elseif K <= 2
pha_rad = 45;
else
pha_rad = 45 + P / 2;
end
% 限制 pha_rad 的值在 15° 和 65° 之间
pha_rad = max(15, min(pha_rad, 65));
pha_rad = pha_rad * (pi / 180);
switch app.DropDown.Value
case ‘竖直滑面法’
if app.Button_2.Value==1
Vc2=4.*pi.*R.^3+pi.*R.^2*(L-2.*R);%体积
Ac2=pi.*R.^2+(L-2.*R).*2.*R;
Lc2=2*pi.*R+(L-2*R).*2;%周长
sigma2=Lc2.*H.*K.*y.*H./2;
Fbc2=Vc2.*10;%
Fbr2=Ac2.*10.*(H-L_s);
F2=Ac2.*P_ya;
Wr2=y.*H.*Ac2;%
t2=Lc2.*c.*H+sigma2.*tan(P)
eq=Wr2+t2==F.*(F2+Fbc2+Fbr2)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
elseif app.Button.Value==1
Vc1=4.*pi.*R.^3;%体积
Ac1=pi.*R.^2;%表面积
Lc1=2*pi.*R;%周长
sigma1=Lc1.*H.*K.*y.*H./2;%水平应力和∑σh
Fbc1=Vc1.*10;%硐室浮力
Fbr1=Ac1.*10.*(H-L_s);%岩体浮力
F1=Ac1.*P_ya;%上抬力
Wr1=y.*H.*Ac1;%重量
t1=Lc1.*c.*H+sigma1.*tan(P)
eq=Wr1+t1==F.*(F1+Fbc1+Fbr1)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
end %How to effectively solve the problem of incompatibility of AppDesigner using symbol toolkit syms after packaging and publishing into exe and other executable files? And how can I change it in my code
cla(app.UIAxes)
P=app.PEditField.Value
P=P.*pi/180;
c=app.CKPaEditField.Value;
K=app.KEditField.Value;%侧压力系数
P_ya=app.P_yaEditField.Value;
F=app.FEditField.Value;
y=app.yKNm3EditField.Value;
R = app.RmEditField.Value;
L=app.LmEditField.Value;
L_s=app.L_smEditField.Value;
syms pha H
term1 = 9 – 12 * (1 – P_ya .* F ./ (y .* H));
term2 = R .* sqrt(term1) – 3 .* R;
denominator = 2 .* H;
% 计算 pha
pha = atan(term2 ./ denominator);
% 显示结果
% disp(pha);
pha_rad=rad2deg(pha);
H_vals = linspace(50, 250, 50);
pha_vals = double(subs(pha_rad, H, H_vals));
% Plot H versus pha
% figure(1);
plot(app.UIAxes,H_vals, pha_vals, ‘b-‘, ‘LineWidth’, 2);
xlabel(app.UIAxes,’H’);
ylabel(app.UIAxes,’pha’);
title(app.UIAxes,’Plot of pha vs H’);
% grid on;
% disp(pha_rad);
%修正破裂角计算
if K <= 1
pha_rad = 45 – P / 2;
elseif K <= 2
pha_rad = 45;
else
pha_rad = 45 + P / 2;
end
% 限制 pha_rad 的值在 15° 和 65° 之间
pha_rad = max(15, min(pha_rad, 65));
pha_rad = pha_rad * (pi / 180);
switch app.DropDown.Value
case ‘竖直滑面法’
if app.Button_2.Value==1
Vc2=4.*pi.*R.^3+pi.*R.^2*(L-2.*R);%体积
Ac2=pi.*R.^2+(L-2.*R).*2.*R;
Lc2=2*pi.*R+(L-2*R).*2;%周长
sigma2=Lc2.*H.*K.*y.*H./2;
Fbc2=Vc2.*10;%
Fbr2=Ac2.*10.*(H-L_s);
F2=Ac2.*P_ya;
Wr2=y.*H.*Ac2;%
t2=Lc2.*c.*H+sigma2.*tan(P)
eq=Wr2+t2==F.*(F2+Fbc2+Fbr2)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
elseif app.Button.Value==1
Vc1=4.*pi.*R.^3;%体积
Ac1=pi.*R.^2;%表面积
Lc1=2*pi.*R;%周长
sigma1=Lc1.*H.*K.*y.*H./2;%水平应力和∑σh
Fbc1=Vc1.*10;%硐室浮力
Fbr1=Ac1.*10.*(H-L_s);%岩体浮力
F1=Ac1.*P_ya;%上抬力
Wr1=y.*H.*Ac1;%重量
t1=Lc1.*c.*H+sigma1.*tan(P)
eq=Wr1+t1==F.*(F1+Fbc1+Fbr1)
H_solution = double(solve(eq, H));
positiveValues = H_solution(H_solution > 0);
app.HEditField.Value=positiveValues;
app.Image.ImageSource = ‘竖直滑面法示意图.png’; % 直接用路径
app.Image_2.ImageSource = ‘竖直滑面法示意图2.png’; % 直接用路径
end matlab gui MATLAB Answers — New Questions
Can anyone help me in understanding of deconvolution based on toeplitz matrix?
First of all, d is a trace whose size is (1,2500), p is a trace whose size is (1,2500).
For d*w=p, which is Dw=p, where D is Toeplitz matrix made by d. Take d and p as an example [1 2 3 4 5].
I construct D that the first column is [1 2 3 4 5 0 0 0 0], the first row is [1 0 0 0 0], which means d lags 2 time step up and 2 time step down, the 0 time lag is place 3 when the first place is 1.
To find w, I use deconvolution, therefore, w=((D^T)D)^(-1)(D^T)p
Confusion comes in here. the number of row of D is 9, however, the p is (1,5) size, how should I concatenate p using 0? Just under the last element of p or two 0 before and two 0 behind?
What I really want to know is the exact form of deconvoution in programs. Really Really appraciate it if anyone could help. Please!First of all, d is a trace whose size is (1,2500), p is a trace whose size is (1,2500).
For d*w=p, which is Dw=p, where D is Toeplitz matrix made by d. Take d and p as an example [1 2 3 4 5].
I construct D that the first column is [1 2 3 4 5 0 0 0 0], the first row is [1 0 0 0 0], which means d lags 2 time step up and 2 time step down, the 0 time lag is place 3 when the first place is 1.
To find w, I use deconvolution, therefore, w=((D^T)D)^(-1)(D^T)p
Confusion comes in here. the number of row of D is 9, however, the p is (1,5) size, how should I concatenate p using 0? Just under the last element of p or two 0 before and two 0 behind?
What I really want to know is the exact form of deconvoution in programs. Really Really appraciate it if anyone could help. Please! First of all, d is a trace whose size is (1,2500), p is a trace whose size is (1,2500).
For d*w=p, which is Dw=p, where D is Toeplitz matrix made by d. Take d and p as an example [1 2 3 4 5].
I construct D that the first column is [1 2 3 4 5 0 0 0 0], the first row is [1 0 0 0 0], which means d lags 2 time step up and 2 time step down, the 0 time lag is place 3 when the first place is 1.
To find w, I use deconvolution, therefore, w=((D^T)D)^(-1)(D^T)p
Confusion comes in here. the number of row of D is 9, however, the p is (1,5) size, how should I concatenate p using 0? Just under the last element of p or two 0 before and two 0 behind?
What I really want to know is the exact form of deconvoution in programs. Really Really appraciate it if anyone could help. Please! deconvolution, toeplitz matrix, digital signal processing MATLAB Answers — New Questions