Histogram from list of bin edges, and bin values

2 ビュー (過去 30 日間)
Filip Henrik Larsen
Filip Henrik Larsen 2016 年 4 月 2 日
コメント済み: Image Analyst 2016 年 4 月 5 日
I have two lists. One containing the borders of the bins, and another the value/height I want this bin to have. They are generated as follows
binBorders = linspace(minimum, maximum, numberOfBins+1);
binValues = zeros(1,numberOfBins);
I then fill the binValues with whatever end would like to make a histogram of this. I am aware that using hist will make a histogram automatically, but the assignment I am trying to solve tells us to do this manually. Any suggestions?

回答 (1 件)

Image Analyst
Image Analyst 2016 年 4 月 2 日
I'll give you this and you can adapt it as you see fit, if you need to
binBorders = linspace(minimum, maximum, numberOfBins+1);
binValues = zeros(1,numberOfBins);
for k = 1 : length(data)
% Find bin
binNumber = find(data(k) > binBorders, 1, 'first');
% Increment the count
binValues(binNumber) = binValues(binNumber) + 1;
end
  1 件のコメント
Image Analyst
Image Analyst 2016 年 4 月 5 日
So Filip, were you able to do it?

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

カテゴリ

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