How to make histogram with volume instead of frequency?
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (2개)
the cyclist
2016년 6월 20일
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
2016년 6월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!