Subplot for individual for loop angle
显示 更早的评论
I am trying to do subplot for each angle like the one below. But when I try to do it it only show the sine wave for all the angle on subplot(2,2,1).
Below is my code
for angle = [0.2 , deg2rad(7.5), deg2rad(30), deg2rad(45)]
for i=1
subplot(2,2,i)
%theta(0) = 0.2 rad
initial_x = [angle;0];
[t,x] = ode45(@fun, t, initial_x);
%figure
hold on
%graph for 0.2 rad of Part A (Non-Linear), plotted in red
plot(t,x(:,2))
%theta(0) = 0.2 rad
initial_y1 = [angle;0];
[t,y] = ode45(@fun1, t, initial_y1);
%graph for 0.2 rad of Part B (Linear), plotted in blue
plot(t,y(:,2))
grid on
title("Angular Velocity VS Time (" +angle+ " rad)")
xlabel('Time (s)')
ylabel('Angular Velocity (\omega)')
legend('Part A (Non-Linear)','Part B (Linear)')
hold off
end
end

2 个评论
Star Strider
2021-11-17
The plots appear to me to be correct.
What is the exact problem? (Also, if solving it requires ‘fun’ and ‘fun1’ they need to be posted.)
.
Jun Hong Wang
2021-11-18
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
