how do i plot (histogram and normal plot) Uniform distribution for uniformly distributed height of a building between 10 to 200?

3 ビュー (過去 30 日間)
height of building uniformly distributed

採用された回答

Image Analyst
Image Analyst 2020 年 10 月 12 日
Sounds like homework so we can't just give you our code to hand in as your own. So look at this example from the help
% Generate a 10-by-1 column vector of uniformly distributed numbers in the interval (-5,5).
r = -5 + (5+5)*rand(10,1)
Adapt the interval from (-5, 5) to (10, 200) in the obvious way (make -5 10 and make the +5 to be 200). Then just pass r into the histogram() function.
  2 件のコメント
Sudeep Gyawali
Sudeep Gyawali 2020 年 10 月 12 日
編集済み: Image Analyst 2020 年 10 月 12 日
I am actually trying to plot the Rayleigh distribution in suburban environment, but first for that I am trying to plot a uniform distribution. I tried in a similar way as you have mentioned but without using histogram().
x = a+(b-a).*rand(1,N);%unifrnd(a,b) %uniformly distributed random variable
c = linspace(a,b,10); %linearly spaced
count(size(c))=0; %count initialize
for i = 1:length(c)-1
for j = 1:length(x) %random variable input
if x(j)>=c(i) && x(j)<c(i+1)
count(i) = count(i) + 1;
end
end
y(i) = (c(i) + c(i+1))/2 ;
end
Z = count(1:end-1)/N;
subplot(211);
bar(y,Z);
subplot(212);
plot(y,Z);
Image Analyst
Image Analyst 2020 年 10 月 12 日
OK. Though that's a funny way to get the histogram (using a double for loop) even if you are doing it manually. You know that 'Rayleigh' is an option for the random() -- not rand() -- function, right?

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

その他の回答 (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