How to insert a normal line over my histograms? i tried using histfit
3 ビュー (過去 30 日間)
古いコメントを表示
sd1 = 1081;
mu1 = 1800;
data1 = mu1+ sd1.*randn(5000,1);
sd2 = 1356;
mu2 = 2551;
data2 = mu2+ sd2.*randn(5000,1);
sd3 = 1262;
mu3 = 2331;
data3 = mu3+ sd3.*randn(5000,1);
%bin specs.
nbins = 100;
bound = 10000;
bins = linspace(-bound,bound,nbins);
fig = figure;
% first histogram
y1 = hist(data1,bins);
% second histogram
y2 = hist(data2,bins);
% Third histogram
y3 =hist(data3,bins);
% overlay histograms
bar(y1.');
hold on;
bar(y2.','r');
hold on;
bar(y3.','y');
legend({'Damage Scenario(i)',' Damage Scenario(ii)',' Damage Scenario(iii)'})
% relabel x-axis range/ticks
xd = findobj('property','XData');
for i=1:3
dat = get(xd(i),'XData');
dat = 2*dat/nbins - bound;
set(xd(i),'XData',data);
h=findobj(gca,'Type','patch');
set(h,'FaceColor','white');
end
4 件のコメント
Ameer Hamza
2020 年 3 月 6 日
histfit works. For example
sd1 = 1081;
mu1 = 1800;
data1 = mu1+ sd1.*randn(5000,1);
sd2 = 1356;
mu2 = 2551;
data2 = mu2+ sd2.*randn(5000,1);
sd3 = 1262;
mu3 = 2331;
data3 = mu3+ sd3.*randn(5000,1);
%bin specs.
nbins = 100;
bound = 10000;
bins = linspace(-bound,bound,nbins);
fig = figure;
ax = axes();
hold(ax);
histfit(data1,nbins);
histfit(data2,nbins);
histfit(data3,nbins);
How does it differ from your intended output?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!