How to draw a histogram of my data?

2 ビュー (過去 30 日間)
Sadiq Akbar
Sadiq Akbar 2020 年 10 月 6 日
コメント済み: Jon 2020 年 10 月 15 日
I have two vectors a and b, where they are as follows:
b=1:100;
a=1e-18:1e-15;
I want to draw a histogram of them such that a is on x-axis and b is on y-axis as shown in the given attachement.
  2 件のコメント
Jon
Jon 2020 年 10 月 6 日
Sadiq Akbar
Sadiq Akbar 2020 年 10 月 6 日
Thank you very much Jon for your prompt response. I checked that but that has a single vector x. I have two vectors a and b.So If I make my "a" vector as x, then where is the role of vector b? So that can't help me.

サインインしてコメントする。

採用された回答

Jon
Jon 2020 年 10 月 6 日
I'm not really sure what you are trying to make a histogram of. It looks like you just want to know how many equally spaced values there are between logarithmically spaced intervals. In this case you don't need the b vector, other than to look at its maximum value which would just set the maximum horizontal scale value. To make sure you don't exceed this value you have to choose your increment properly. Maybe you are looking for something like this?
numBins = 20;
maxCount = 100;
% calculate increment so that maxCount will not be exceeded
delta = (1e-15 - 1e-18)/(numBins*maxCount);
% generate your equally space data
a=1e-18:delta:1e-15;
% make your histogram
histogram(a,numBins)
set(gca,'xscale','log') %scale the x-axis logarithmically
  7 件のコメント
Jon
Jon 2020 年 10 月 12 日
If it will not run in the older version, then I assume that this feature was added in a more recent version. I don't have an older version to test in. Unless there is something preventing you from doing so I would highly recommend staying up to date with the current version to avoid such problems.
Jon
Jon 2020 年 10 月 15 日
If I have answered your question please accept this answer so that others who might have a similar question will know that an answer is availble.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by