How to re-bin histograms with wider bins?

5 ビュー (過去 30 日間)
pietro
pietro 2015 年 1 月 9 日
回答済み: Image Analyst 2015 年 1 月 9 日
Hi all,
How may I rebin an histogram in wider bins? Here an axample:
0-1 4
1-2 5
2-3 1
3-4 4
4-5 5
the result may be:
0-2 9
2-4 5
4-6 5
Thanks
Regards
Pietro

回答 (2 件)

Image Analyst
Image Analyst 2015 年 1 月 9 日
Simply use histc() - that's what it's meant for. Just pick the "edge" locations of your bins to be whatever you want them to be
edges = 0 : 2 : 6;
counts = histc(data, edges);

Marius
Marius 2015 年 1 月 9 日
Hi Pietro,
That might get you startet on a solution.
bins = [4 5 1 4 5 0];
bins must have even number of elements, if not you could pad an 0 at the end
if mod(numel(bins),2)
bins(end+1) = 0;
end
new_bins = bins(1:2:end) + bins(2:2:end);
| |- 2)and add every second element starting with the second element
|
|- 1) take every second element starting with the first
new_bins is now [9 5 5]
Marius

カテゴリ

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