histogram vector with deltaN specified
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
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?
Réponses (2)
Image Analyst
le 22 Oct 2017
0 votes
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 commentaires
Viesturs Veckalns
le 22 Oct 2017
Image Analyst
le 22 Oct 2017
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
le 22 Oct 2017
Walter Roberson
le 22 Oct 2017
Count regularly and then multiply the bin counts by your weights.
Viesturs Veckalns
le 23 Oct 2017
Guillaume
le 23 Oct 2017
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')
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!