Subplots in a loop while the graphs keep changing
Mostrar comentarios más antiguos
I have several for loops working at the same time and I would like each graph to be plotted in a figure with 4x3 plots. This is what I have now
There are 4 different values for b and 3 for F.
for i = 1:length(b)
b_loop = b(i);
for j = 1:length(F)
F_loop = F(j);
for n=1:N
tbar = t(n)+h/2;
ybar = y(n)+(h/2)*(dy(n));
dybar = dy(n)+h/2*((F_loop*cos(w(1)*t(n)))/m-(b_loop*dy(n)/m)-(w0^2*y(n)));
y(n+1) = y(n)+h*(dybar);
dy(n+1) = dy(n)+h*((F_loop*cos(w(1)*t(n)))/m-(b_loop*dybar/m)-(w0^2*ybar));
t(n+1) = t(n)+h;
end
subplot(4,3, ????)
plot(t,y, t,dy)
title(sprintf('F = %d, b = %d', F(j), b(i)))
xlabel('Time [s]')
ylabel('Position [m] & Velocity [m/s]')
legend('position', 'velocity')
end
end
When I use "figure" instead of "subplot" I get the 12 graphs that I want in 12 different windows, but I want each graph that comes out to be placed in one windows also it the right subplot.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Subplots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!