Cumulative histogram with bin being values greater than or equal.
7 views (last 30 days)
Show older comments
Edward Chen
on 19 Dec 2021
Answered: Image Analyst
on 19 Dec 2021
I'm trying to plot a dose volume histogram and I know that I can use histogram(X, 'Normalization', 'cdf') in order to plot a cumulative distributive histogram where each bin is all values less than or equal to the bin value. However, I would like to have a histogram where each bin is all values greater than or equal to the bin value. Does anyone know of a simple way to accomplish that in MATLAB?
0 Comments
Accepted Answer
Image Analyst
on 19 Dec 2021
Do you mean like this:
data = randn(100000, 1);
[counts, edges] = histcounts(data)
subplot(3, 1, 1);
bar(edges(1:end-1), counts)
grid on;
xlabel('Value')
ylabel('Counts')
title('Histogram')
% Compute cdf
cdf = rescale(cumsum(counts), 0, 100);
subplot(3, 1, 2);
bar(edges(1:end-1), cdf);
grid on;
xlabel('Value')
ylabel('Percent')
title('CDF')
% where each bin is all values greater than or equal to the bin value.
subplot(3, 1, 3);
bar(edges(1:end-1), 100-cdf); % or fliplr(cdf)
grid on;
xlabel('Value')
ylabel('Percent')
title('CDF')
0 Comments
More Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!