How to get the data as output along with the histogram plot?

7 views (last 30 days)
Hi,
I have a set of data which looks like
0.499783
0.499669
0.500231
0.499909
0.499542
0.50018
0.500785
0.49823
.... and so on (say I haev 50000 rows)
Now I am plotting
histogram(S,'Normalization','probability') , where S is the column containing the data.
I get the normalized probability histogram as a plot. But I want the data that is finally plotted, i.e., no. of hits in each bin or something like that. Such that in future I can get the same histogram plot without using the original raw data. Is that possible?

Accepted Answer

Tommy
Tommy on 1 Jun 2020
You could request output from histogram():
h = histogram(S,'Normalization','probability');
and access properties such as h.BinEdges, h.BinCounts, h.Values, etc, described here.
Or you could use histcounts(), described here, after you plot your histogram:
histogram(S,'Normalization','probability');
[binCounts,binEdges] = histcounts(S,'Normalization','probability');
  5 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!