Reputation: 16255
I have a mean and standard deviation, I want to plot a normal curve with no labels on the axis and no grid lines. I have searched and found this:
r = mean + std.*randn(100,1);
histfit(r)
But this has the histogram bars, and grid lines and axis tickers.
Thanks
Upvotes: 2
Views: 22129
Reputation: 11
You can use Normal probability density function. This, combined with Eitan T's answer, would give
mu = 4; %// Mean
sigma = 0.2 %// Standard deviation
%// Plot curve
x = (-5 * sigma:0.01:5 * sigma) + mu; %// Plotting range
plot(x, normpdf(x,mu,sigma));
%// Hide ticks
set(gca, 'XTick', [], 'XTickLabel', [], 'YTick', [], 'YTickLabel', [])
and would result in the same figure. Only that you would use a MATLAB in-built function instead of coding it on your own.
Upvotes: 0
Reputation: 32930
Just compute the corresponding Gaussian curve and plot it.
Let's plot a Gaussian curve with 4 mean and 0.2 standard deviation:
mu = 4; %// Mean
sigma = 0.2 %// Standard deviation
%// Plot curve
x = (-5 * sigma:0.01:5 * sigma) + mu; %// Plotting range
y = exp(- 0.5 * ((x - mu) / sigma) .^ 2) / (sigma * sqrt(2 * pi));
plot(x, y)
%// Hide ticks
set(gca, 'XTick', [], 'XTickLabel', [], 'YTick', [], 'YTickLabel', [])
The result is:
Upvotes: 4
Reputation: 308763
Since you have mean and standard deviation, why can't you just plot this?
https://en.wikipedia.org/wiki/Normal_distribution
That's the function you're interested in. Just loop over values in the range of
(mean - 3*stddev) <= x <= (mean + 3*stddev)
Upvotes: 0