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!
