histogram vector with deltaN specified

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?

답변 (2개)

Image Analyst
Image Analyst 2017년 10월 22일

0 개 추천

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

Viesturs Veckalns
Viesturs Veckalns 2017년 10월 22일
As N (counts) is the y axis, deltaN specifies how many counts must be added to that bin.
Image Analyst
Image Analyst 2017년 10월 22일
Does anyone else understand this? The number of counts you add to the bin is just the number of counts you add to the bin. And that is done by histogram() or histcounts(), so is there any further problem?
Viesturs Veckalns
Viesturs Veckalns 2017년 10월 22일
Instead of adding 1, specify to add 20 or 0.5 to the count
Walter Roberson
Walter Roberson 2017년 10월 22일
Count regularly and then multiply the bin counts by your weights.
Viesturs Veckalns
Viesturs Veckalns 2017년 10월 23일
1. The histogram will be displayed incorrectly
2. This will require me to count the weights myself
Guillaume
Guillaume 2017년 10월 23일

0 개 추천

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')

이 질문은 마감되었습니다.

태그

질문:

2017년 10월 22일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by