Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 11 Ott 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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by