How to use a subplot in a for loop
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Star Strider
2019 年 4 月 21 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!