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!