Gaussian Distribution

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 comentario

Adam Danz
Adam Danz el 14 de Jul. de 2020
Here's a gaussian function where you can set the mean, standard deviation, amplitude, and vertical offset.

Iniciar sesión para comentar.

 Respuesta aceptada

Honglei Chen
Honglei Chen el 17 de Feb. de 2012

1 voto

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 comentarios

Hein Htet Aung
Hein Htet Aung el 23 de Abr. de 2016
Editada: Walter Roberson el 11 de Nov. de 2025
x = linspace((mu-4*sd),(mu+4*sd),1000);
makes better looking plots.
Kunal Lakhani
Kunal Lakhani el 20 de Oct. de 2016
Clarification of the formula of gaussian distribution.
@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);

Iniciar sesión para comentar.

Más respuestas (2)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou el 28 de Dic. de 2024

0 votos

To learn more about normal or Gaussian distribution, read the topic Normal Distribution.
Liam Walsh
Liam Walsh el 11 de Nov. de 2025

0 votos

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)
normdist =
NormalDistribution Normal distribution mu = 4 sigma = 2
plot(normdist) % Automatically shows a graph of the distribution

Preguntada:

KB
el 17 de Feb. de 2012

Editada:

el 11 de Nov. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by