Histogram from numberdensity values.

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 ?
Venkatesh Pandian narayanasamy
Venkatesh Pandian narayanasamy 2023 年 1 月 6 日
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:

カテゴリ

製品

リリース

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