Gaussian Distribution
189 次查看(过去 30 天)
显示 更早的评论
Hi All, I am trying to plot a amplitude Gaussian distribution in Matlab. I have only amplitude peak, mean and sigma (sd) values. The peak is corresponding to the mean. How to get a Gaussian normal plot using only that three values? What could be the code for that?
1 个评论
Adam Danz
2020-7-14
Here's a gaussian function where you can set the mean, standard deviation, amplitude, and vertical offset.
采纳的回答
Honglei Chen
2012-2-17
This is really just plotting an equation, for practical purpose, you can plot from -4*sd to 4*sd. Let's say mu is the mean,
x = linspace(-4*sd,4*sd,1000);
y = 1/(2*pi*sd)*exp(-(x-mu).^2/(2*sd^2));
plot(x,y);
3 个评论
Adam Danz
2021-5-1
@Mohammed Ghouse Mohiuddin, in response to your flag > The code is incorrect, you just have to define mu and sd.
mu = 10;
sd = 4;
x = linspace(-4*sd,4*sd,1000);
y = 1/(2*pi*sd)*exp(-(x-mu).^2/(2*sd^2));
plot(x,y);
更多回答(2 个)
Liam Walsh
2025-11-11,18:33
If you have access to Statistics and Machine Learning toolbox, you can also make use of the makedist function, like so:
mu = 4; % Mean/amplitude value
sigma = 2; % Sigma/sd value
normdist = makedist("normal", "mu", 4, "sigma", 2)
plot(normdist) % Automatically shows a graph of the distribution
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

