hi all, I have the following code to plot 5 different subplot hist. for 5 different matrices but it has the same dim. for each
x=-0.09 : 0.01 : 0.9;
hist(Y,x)
h = findobj(gca,'Type','patch');
set(h,'FaceColor','k','EdgeColor','w')
axis([-0.12 0.12 0 200])
I want to use for loop to plot it (i.e. Y is the changed matrix that mentioned above) can anyone help me to do it? thank you in advance.

2 件のコメント

José-Luis
José-Luis 2016 年 9 月 27 日
I don't get it.
for ii = 1:5
Y = someFunction
subplot(1,5,ii)
histogram(Y)
end
Lilya
Lilya 2016 年 9 月 28 日
thank you José. I mean I have 5 different separated matrices to plot each using subplot The written code is working with only one matrix but does not appear the other 4 Thank you again

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

 採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 9 月 28 日
編集済み: Massimo Zanetti 2016 年 9 月 28 日

3 投票

Assume your five matrices are Y1,Y2,Y3,Y4,Y5. Then, put them in a cell and then run a for loop:
Y = {Y1,Y2,Y3,Y4,Y5};
x=-0.09 : 0.01 : 0.9;
for k=1:5
figure;
hist(Y{k},x);
h = findobj(gca,'Type','patch');
set(h,'FaceColor','k','EdgeColor','w');
axis([-0.12 0.12 0 200]);
end

1 件のコメント

Lilya
Lilya 2016 年 9 月 28 日
Thanks a lot :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2016 年 9 月 27 日

編集済み:

2016 年 9 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by