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

조회 수: 5 (최근 30일)
Jae Min Lee
Jae Min Lee 2018년 9월 30일
댓글: Star Strider 2018년 9월 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
Jae Min Lee
Jae Min Lee 2018년 9월 30일
Thanks. However i do not know why the threshold is 0.1.
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