フィルターのクリア

I am trying to plot a Gaussian normal probability density function with 500 points, mean=1.5 standard deviation 0.5. The Below is my code. My code doesn't have a error but the plot is not accurate.

1 回表示 (過去 30 日間)
I am trying to plot a Gaussian normal probability density function with 500 points, mean=1.5 standard deviation 0.5. The Below is my codecode doesnt have a error but the plot is not accurate.
function
function f = gauss_distribution(x, mu, s)
p1 = -.5 * ((x - mu)/s) .^ 2;
p2 = (s * sqrt(2*pi));
f = exp(p1) ./ p2;
end
code:
x = [xmin:xmax];
m = 1.5
s = 0.6
N=500;
xmax= m+ N/2*s;
xmin = m- N/2*s;
f = gauss_distribution(x, m, s);
plot(x,f,'.')
grid on
xlabel('Randomly produced numbers')
ylabel('Gauss Distribution')
Plot: is attached

採用された回答

Jose Marques
Jose Marques 2017 年 9 月 10 日
Hello Sam. I used:
Y = normpdf(x,m,s)
and give the same result.
Seems that is correct.
  3 件のコメント
Sam17
Sam17 2017 年 9 月 10 日
i was asked to generate x values in similar manner in my question.
Sam17
Sam17 2017 年 9 月 10 日
I am not getting the exact plot.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by