How to make histogram with volume instead of frequency?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a column vector 'temp' with values of temperature, and an associated column vector 'vol' with values of volume. In other words, each temperature is associated with a volume.
I would like to create a histogram of temperature, BUT, instead of having each bin represent frequency, I would like it to represent volume fraction. (so, for example, the first bin might be 0ºc to 80ºc and have a value of 0.25, meaning 1/4 if the total volume has a temperature from 0ºc to 80ºc).
I am very new to Matlab, so I would appreciate a solution which is easy to understand and implement. Is what I'm looking for called a weighted histogram? Searching the forums for this term doesn't return much.
0 Kommentare
Antworten (2)
the cyclist
am 20 Jun. 2016
From your description, it sounds like you don't need the calculation part of what a histogram calculates, and you already have the y value. If that is the case, then you can just use the bar function, like this
T = [1 2 3 4];
V = [0.25 0.15 0.40 0.20];
figure
bar(T,V)
the cyclist
am 22 Jun. 2016
Ah, from your comment on my other answer, I understand better. You might have had temps
T = [2, 12, 18, 27, 79]
that you need gathered together, and collectively they account for 0.25.
I can't write up a complete example right now, but you might be able to use the accumarray function to do this. It might not be simple to automate the binning part, though.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!