Dear All,
I have a data of x and y, where x is the radius of the particles and y denotes the number density of particles that has radius in x. Now I would like to make a histogram, could you kindly help me with it.
Sample Data:
x = [6 5 3 23 67 33 74]
y = [5 8 2 4 9 2 1] *1e24
Thanks in advance

댓글 수: 2

Torsten
Torsten 2023년 1월 6일
편집: Torsten 2023년 1월 6일
Why does the 3 appear two times in x with different associated number densities ?
That was a mistake, it is supposed to be
x = [6 5 3 23 67 33 74]
y = [5 8 2 4 9 2 1] *1e24

댓글을 달려면 로그인하십시오.

답변 (2개)

the cyclist
the cyclist 2023년 1월 6일

0 개 추천

Is this bar graph what you need? If not, can you explain a bit more?
x = [6 5 3 23 67 33 74];
y = [5 8 2 4 9 2 1] *1e24;
bar(x,y)
Image Analyst
Image Analyst 2023년 1월 6일

0 개 추천

That already is a histogram. It's just badly named. x is the histogram bin value (represents radius), and y is the histogram count value (representing what you call "density" but is the number of data points with the associated x (radius) value. You can plot this histogram simply with the bar function.
x = [6 5 3 23 67 33 74];
y = [5 8 2 4 9 2 1] *1e24;
bar(x, y);
xlabel('radius')
ylabel('Count')
title('Histogram of Radii')
grid on;
The histogram function is not needed because your x and y are already a histogram. You don't need to "make a histogram" because you already have it. If you want to normalize it by dividing by the tallest value, or the sum of all values, you could of course do that.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

제품

릴리스

R2022a

답변:

2023년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by