unshow unnecessary intervalls in a histogramm
1 view (last 30 days)
Steven Lord on 22 Jul 2021
x = randn(1, 1e5);
h = histogram(x);
C = h.BinCounts;
E = h.BinEdges;
C([30:40 50 60]) = 0;
histogram('BinCounts', C, 'BinEdges', E)
If you don't want to plot both histograms you could use histcounts to compute C and E instead of calling histogram.
More Answers (1)
Constantino Carlos Reyes-Aldasoro on 22 Jul 2021
What you need to do is rather simple if you capture the values of your histogram, instead of using hist to display directly, For example take the data to be 500 Gaussian randomly distributed points. Take the histogram and save the values in x,y and then display:
This is the equivalent of what you currently have, now you want to discard some of the bins produced, first let's see the size of x (and y would be the same):
numBins = numel(x)
So we know that it has 41 values, now, create a vector with those values that you want to keep and remove those you do not want, say you want to remove 11,21,22,23,24:
selected_bins=[1:10 12:20 25:numBins];
And that's it, you have a histogram with only the values you had selected.
Hope this solves your question. If yes, please accept the answer, if not, let me know.