I have a bunch of data and I want to plot the Histogram graph of them. However, I need to have the percentage of the number of data with respect to the total number of them, instead of just the number of data located at each interval. For example if
X = [1 1 2 3 4]
I want the value of the first interval to be 40 (%) instead of 2; that is 2/5 * 100
I used:
tem_store = hist(x)
and I tried to use "Bar" instead of "Hist"; but in that case the intervals are not positioned like the Histogram and bins are separated.
I would be very thankful if any one can help me out.
Regards,
Farhad.
clc;
close all;
workspace; % Display workspace panel.
x = 4 * rand(1, 1000);
subplot(2,2,1);
plot(x);
xlabel('Index');
ylabel('Input Value');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
numberOfBins = 16;
[counts, binValues] = hist(x, numberOfBins);
subplot(2,2,2);
bar(binValues, counts, 'barwidth', 1);
xlabel('Input Value');
ylabel('Absolute Count');
normalizedCounts = 100 * counts / sum(counts);
subplot(2,1,2);
bar(binValues, normalizedCounts, 'barwidth', 1);
xlabel('Input Value');
ylabel('Normalized Count [%]');
Thanks a lot for your comprehensive reply. I really like your example.
Cheers,
Farhad.
ImageAnalyst <imagea...@mailinator.com> wrote in message <4a861baa-2f5d-4542...@b9g2000yqd.googlegroups.com>...