I am currently to plot in MATLAB App designer but only one figure gets plotted and the code for second figure gets ignored

1 次查看(过去 30 天)
This is what I get in out put but my code is this. (Please ignore the code just see that in code I have also used "plot(app,UIAxes2))" But still no plot for figure 2.
My app window is this
My code is following
L = app.LengthofSimulationSlider.Value; % Pendulum length in meters
Angle(1) = app.InitialAngleSlider.Value; % Initial Angle of Pendulum in Radians
g = 9.81; % Gravitational Acceleration
h = 0.04; % Step length for Time
Omega(1) = 0; % Initial value for Angular Velocity
time = app.LengthofSimulationSlider.Value; % Simulation for Seconds
Time = 0:h:time;
x_data(1)= L*sin(Angle(1)); % x-corodinate
y_data(1)= -L*cos(Angle(1)); % y-corodinate
for i = 2:length(Time)
Omega(i) = Omega(i-1) - h*g*sin(Angle(i-1))/L; % Equation 1 Solution
Angle(i) = Angle(i-1) + h*Omega(i); % Equation 2 Solution
x_data(i)= L*sin(Angle(i)); % x-corodinate
y_data(i)= -L*cos(Angle(i)); % y-corodinate
end
for j = 1:length(Angle)
% Plot on UIAxes
cla(app.UIAxes)
plot(app.UIAxes,Time,Angle,'k-','linew',1.5)
hold(app.UIAxes,'on')
plot(app.UIAxes,Time(j),Angle(j),'ro','markersize',5,'markerfacecolor','r')
axis(app.UIAxes,[Time(1) Time(end) -3 3])
% Plot on UIAxes2
cla(app.UIAxes2)
plot(app.UIAxes2,1:10,2:11,'b','linew',3);
hold(app.UIAxes2,'on')
plot(app.UIAxes2,[0 0],[0 0],'bo','markersize',7,'markerfacecolor','b')
plot(app.UIAxes2,[0 x_data(j)],[0 y_data(j)],'r-','linew',2,'markerfacecolor','r')
plot(app.UIAxes2,[0 x_data(j)],[0 y_data(j)],'bo','markersize',7,'markerfacecolor','b')
axis(app.UIAxes2,'equal')
axis(app.UIAxes2,[-L-1 L+1 -3 3])
pause(0.00005)
end
please helpppp !!!!!!!!!!!
If you dont understand anything just ask but please help It wont take any more than 5 seconds for expertsss
  3 个评论
Haseeb Hashim
Haseeb Hashim 2022-12-7
Many thanks to you guys. I was stuck here from a long time. Many Many thanks again..........
MATLAB would be a nightmare for us amateurs without you guyz.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by