Gaussian Distribution

144 views (last 30 days)
KB
KB on 17 Feb 2012
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 Comment
Adam Danz
Adam Danz on 14 Jul 2020
Here's a gaussian function where you can set the mean, standard deviation, amplitude, and vertical offset.

Sign in to comment.

Accepted Answer

Honglei Chen
Honglei Chen on 17 Feb 2012
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 Comments
Kunal Lakhani
Kunal Lakhani on 20 Oct 2016
Clarification of the formula of gaussian distribution.
Adam Danz
Adam Danz on 1 May 2021
@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);

Sign in to comment.

More Answers (1)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou on 28 Dec 2024
To learn more about normal or Gaussian distribution, read the topic Normal Distribution.

Community Treasure Hunt

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

Start Hunting!