How to use a subplot in a for loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
syms y x
y = acos(x);
fplot(y), hold on
for n = [3 5 7]
yk = taylor(y, x, 'Order', n);
fplot(yk), hold on
end
legend('y', 'T3(x)', 'T5(x)', 'T7(x)')
I have the above code which plots my graphs on the same graph but I want them on different graphs but the same figure...how do I do this?
0 Kommentare
Antworten (1)
Star Strider
am 21 Apr. 2019
I am not certain what you want.
Try this:
syms y x
y = acos(x);
n = [3 5 7]
ttlc = {'y', 'T3(x)', 'T5(x)', 'T7(x)'};
hold all
subplot(numel(n)+1, 1, 1)
fplot(y)
title(ttlc(1))
for k = 1:numel(n)
subplot(numel(n)+1, 1, k+1)
yk = taylor(y, x, 'Order', n(k));
fplot(yk)
title(ttlc(k+1))
end
hold off
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!