Subplot for individual for loop angle
Mostra commenti meno recenti
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 Commenti
Star Strider
il 17 Nov 2021
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
il 18 Nov 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Spline Postprocessing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
