Info
此问题已关闭。 请重新打开它进行编辑或回答。
histogram vector with deltaN specified
1 次查看(过去 30 天)
显示 更早的评论
I have a vector x
x = [1.7 2.2 1.7 3.0 2.2]
also I have a deltaN associated with each value in x
deltaN = [0.1 1.0 3.0 0.7 0.7]
How can I instruct Matlab to increase the count in bin corresponding to x(i) by deltaN(i), not 1?
0 个评论
回答(2 个)
Image Analyst
2017-10-22
What is deltaN? You can specify the edges of the bins if that's what you're asking about. See the documentation for histogram() or histcounts().
5 个评论
Guillaume
2017-10-23
There are no weighted histogram function in matlab as far as I know. It's not really hard to implement:
x = [1.7 2.2 1.7 3.0 2.2];
deltaN = [0.1 1.0 3.0 0.7 0.7];
[~, ~, bin] = histcounts(x); %add whichever option you want to histcount
h = accumarray(bin', deltaN')
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!