How can I plot the profile/skyline of an histogram from histcounts?

16 ビュー (過去 30 日間)
Sim
Sim 2022 年 3 月 9 日
コメント済み: Sim 2022 年 3 月 9 日
Hi, how can I plot the profile/skyline of an histogram from histcounts?
This is my attempt with the function stairs, which does not work:
X = normrnd(3,10,[1,1000]);
[values, edges] = histcounts(X,100);
stairs(edges,values)
However, if possible, I would like to use the plot function instead of stairs.

採用された回答

Steven Lord
Steven Lord 2022 年 3 月 9 日
If you have to go through histcounts first:
X = normrnd(3,10,[1,1000]);
[values, edges] = histcounts(X,100);
h = histogram('BinCounts', values, 'BinEdges', edges, 'DisplayStyle', 'stairs');
But if you don't have to go through histcounts first, just use histogram directly.
h = histogram(X, 100, 'DisplayStyle', 'stairs');
You get the same values and edges.
values2 = h.BinCounts;
edges2 = h.BinEdges;
isequal(edges, edges2)
ans = logical
1
isequal(values, values2)
ans = logical
1

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by