I want to adjust the x-axis according to the histogram distribution.

5 次查看(过去 30 天)
A simple example is shown in the following image.
It does not mean histogram smoothing.

回答(2 个)

Star Strider
Star Strider 2018-9-30

I am not certain what you want to do.

Try this:

x = 0:50;                               % Create Data
y = exp(-0.1*x);                        % Create Data
mask = y >= 0.1;                        % Select Data Greater Than A Threshold Value
figure
subplot(2,1,1)
bar(x, y)
subplot(2,1,2)
bar(x(mask), y(mask))

It selects values for ‘y’ greater than a threshold value, then plots only those values in the second subplot. Note that you must use the bar plot for this, so you will need to use histcounts or related functions first.

  2 个评论
Star Strider
Star Strider 2018-9-30
You can set the threshold to be anything you want. The value of the threshold and how you calculate it depends on your data.
For example, using histcounts (link):
x = 0:50; % Create Data
data = exp(-0.1*x); % Create Data
nbins = 30;
[N,edges] = histcounts(data,nbins); % Histogram
mask = N >= 0.1*max(N); % Define Conditions Based On Histogram Frequencies
ctrs = edges(1:end-1) + mean(diff(edges)); % Calculate Centres
figure
subplot(2,1,1)
bar(ctrs, N)
subplot(2,1,2)
bar(ctrs(mask), N(mask))
Without your data, I cannot be more specific.

请先登录,再进行评论。


Image Analyst
Image Analyst 2018-9-30

Maybe you want

xlim([0, 0.02]); % Make the x axis go from 0 to 0.02.

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by