フィルターのクリア

Subplot of bar graph within for loop

1 回表示 (過去 30 日間)
Betty
Betty 2017 年 12 月 8 日
コメント済み: Betty 2017 年 12 月 8 日
Hi guys.
I'm trying to make a subplot of 7 bar graphs in my for loop, but I can't make it work.
My code looks like this:
for ii =1:7
for i = 1:10
temp1 (i,1) = Orig(i,ii);
temp1 (i,2) = Reg(i,ii);
end
figure;
subplot(1,2,1);
bar(temp1);
ylabel('Degrees')
xlabel('Epochs')
end
I want all my subplot in 1 figure, in this case when I run my code, I have 7 figures.
Thanks, B!

採用された回答

KL
KL 2017 年 12 月 8 日
編集済み: KL 2017 年 12 月 8 日
The command
figure;
creates a new figure everytime. You should move it outside both loops. And also the position of the subplot should be mentioned using the loop iterators,
subplot(7,1,ii)
otherwise your subplots will be overwritten every time.
  3 件のコメント
KL
KL 2017 年 12 月 8 日
Just use title after you plot each time,
title(['case ' num2str(ii)])
Betty
Betty 2017 年 12 月 8 日
It works, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by