MATLAB: Does this probability density function looks off

pdfplotprobabilitystatistics

I have a random variable x which has a mean of 10 and a variance of 16. I used the following code to generate the array and the PDF:
x= randn(100,1) * sqrt(16)+10;
mu = 10;
sigma = 4;
pd = makedist('Normal',mu,sigma);
y=pdf(pd,x);
hist(y)
Should i be plotting with something other than hist or is x itself wrong? Thank you.

Best Answer

The mistake is in using hist. Plot x vs. y instead, because y is the value of the pdf itself.

x= randn(100,1) * sqrt(16)+10;
mu = 10;
sigma = 4;
pd = makedist('Normal',mu,sigma);
y=pdf(pd,x);
figure
plot(x,y,'.')