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!
