How to display multiple histogram with one run

108 ビュー (過去 30 日間)
Mustafa Vural
Mustafa Vural 2020 年 9 月 17 日
コメント済み: Mustafa Vural 2020 年 9 月 19 日
I am generating random numbers (data) with the 3 parameter weibull distribution.
In my code, I have 25 combinations of my parameters (b=1:5; T=1:5) and I want to display every single combination as a histogram.
So at the end, I have 25 histogram of data.
The problem is, only the last combination of my parameter ( b=5, T=5) is displayed.
How can I see ALL 25 histograms with one run?
Edit: I deleted the 2 parameter weibull in my code for better overview about my question.
clear all;
n = 100;
t0 = 0.5;
b = 1:5;
T = 1:5;
for v_T = 1:length(T)
for v_b = 1:length(b)
data(:,v_b,v_T) = wblrnd(v_T,v_b, [n,1]) + t0;
end
end
histogram (data)
ax = gca;
get(ax, 'position')
ax.XLim=[0,10];

採用された回答

Vinicius Pereira Mateus Borges
Vinicius Pereira Mateus Borges 2020 年 9 月 17 日
Hello Mustafa, you can use subplots inside for loops.
clear all;
n = 100;
t0 = 0.5;
b = 1:5;
T = 1:5;
clf
figure(1)
loopVar = 0;
for v_T = 1:length(T)
for v_b = 1:length(b)
data(:,v_b,v_T) = wblrnd(v_T,v_b, [n,1]) + t0;
subplot(length(T),length(b), v_b + loopVar)
histogram (data)
ax = gca;
get(ax, 'position')
ax.XLim=[0,10];
end
loopVar = loopVar + length(T)
end
  5 件のコメント
Mustafa Vural
Mustafa Vural 2020 年 9 月 19 日
Thank you for the advice, I will five it a try!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 9 月 17 日
You did not put in
hold on
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 17 日
Well you can use subplot() or you can use the newer tiled layout operations, if you want all the histograms to appear in the same figure but diffrent axes.
Or you can add a call to figure() to create a new figure each time.

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

カテゴリ

Find more on 2-D and 3-D Plots in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by