how to plot a gaussian 1D in matlab
Show older comments
for k = 1 : K
ax = linspace(min_x,max_x,100);
y = my_gaussian(x,means,vars);
plot(ax,y);
end
Accepted Answer
More Answers (2)
You can use Matlab function to construct Gaussian function :
x = 0:0.1:10;
y = gaussmf(x,[2 5]);
plot(x,y)

4 Comments
Gadadhar Sahoo
on 1 Dec 2017
Edited: Gadadhar Sahoo
on 1 Dec 2017
M
on 1 Dec 2017
Did you read the documentation ? Those are the second parameter you give to the function gaussmf(x,[sigma,mean]) .
Gadadhar Sahoo
on 1 Dec 2017
Chad MacDonald
on 2 Aug 2023
Edited: Chad MacDonald
on 12 Nov 2024
Do not use the gaussmf function from Fuzzy Logic Toolbox to compute a Gaussian distribution. This function evaluates a Gaussian membership function for a fuzzy logic system, which is not the same thing as a Gaussian distribution. For more information on Gaussian probability distributions, see Normal Distribution.
Chad MacDonald
on 12 Nov 2024
Edited: Chad MacDonald
on 12 Nov 2024
If you have Statistics and Machine Learning Toolbox, you can compute a Gaussian probability distributon using the normpdf function. For example, the following code computes and plots a normal distribution with a mean of 5 and a standard deviation of 1.
x = 0:0.1:10;
mu = 5;
sigma = 1;
y = normpdf(x,mu,sigma);
plot(x,y)
Categories
Find more on Exploration and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



