Borrar filtros
Borrar filtros

How can I assign plotting properties to a subplot within a loop

1 visualización (últimos 30 días)
I have this loop to plot some values,
for k = 1:3
figure(1)
subplot(3,1,k)
plot(t{1},A{k})
title('Acceleration v Time 480 CFH')
xlabel('Time (s)')
ylabel('Acceleration (g)')
grid on
%xlim([1 185])
orient(figure(1),'landscape')
print('480CFH Acceleration Open Hole','-dpdf','-fillpage')
end
And I need to apply a set of ylim to the first two subplots and a different set to the third. I tried using something like this,
if k < 3
ylim([-0.2 0.2])
else ylim([-2 0])
end
But this did nothing to the plot. I put this code after the ylabel line.

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 11 de Oct. de 2019
Hi,
You have done well in all steps except for one small point after else condition:
for k = 1:3
figure(1)
subplot(3,1,k)
plot(T{k},F{k})
title('Acceleration v Time 480 CFH')
xlabel('Time (s)')
ylabel('Acceleration (g)')
grid on
%xlim([1 185])
orient(figure(1),'landscape')
print('480CFH Acceleration Open Hole','-dpdf','-fillpage')
if k < 3
ylim([-0.2 0.2])
else
ylim([-2 0])
end
end
Now it is working.
Good luck.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by