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

4 Ansichten (letzte 30 Tage)
Jae Min Lee
Jae Min Lee am 30 Sep. 2018
Kommentiert: Star Strider am 30 Sep. 2018
A simple example is shown in the following image.
It does not mean histogram smoothing.

Antworten (2)

Star Strider
Star Strider am 30 Sep. 2018

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 Kommentare
Jae Min Lee
Jae Min Lee am 30 Sep. 2018
Thanks. However i do not know why the threshold is 0.1.
Star Strider
Star Strider am 30 Sep. 2018
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.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 30 Sep. 2018

Maybe you want

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

Community Treasure Hunt

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

Start Hunting!

Translated by