Draw Normal Distribution Graph of a Sample in Matlab

ManiAm picture ManiAm · Aug 6, 2012 · Viewed 43.8k times · Source

I have 100 sampled numbers, and I need to draw the normal distribution curve of them in matlab.

The mean and standard deviation of these sampled data can be calculated easily, but is there any function that plots the normal distribution?

Answer

Sam Roberts picture Sam Roberts · Aug 6, 2012

If you have access to Statistics Toolbox, the function histfit does what I think you need:

>> x = randn(10000,1);
>> histfit(x)

Normal distribution plot

Just like with the hist command, you can also specify the number of bins, and you can also specify which distribution is used (by default, it's a normal distribution).

If you don't have Statistics Toolbox, you can reproduce a similar effect using a combination of the answers from @Gunther and @learnvst.