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

5 visualizaciones (últimos 30 días)
Jae Min Lee
Jae Min Lee el 30 de Sept. de 2018
Comentada: Star Strider el 30 de Sept. de 2018
A simple example is shown in the following image.
It does not mean histogram smoothing.

Respuestas (2)

Star Strider
Star Strider el 30 de Sept. de 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 comentarios
Jae Min Lee
Jae Min Lee el 30 de Sept. de 2018
Thanks. However i do not know why the threshold is 0.1.
Star Strider
Star Strider el 30 de Sept. de 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.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 30 de Sept. de 2018

Maybe you want

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

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by