pdf of an uniform distribution in matlab?

1.8k Views Asked by At

I'm reading a book and I came across a problem in which I should generate a uniform random variable and use hist, mean and std to compute the $pdf$, $m_{v}$ and $\sigma_{v}$. Note: I have to normalize the hist. This is what I did

x = rand(10000,1);
m = mean(x);
v = std(x);
pdf = hist(x);
pdf = pdf./sum(pdf);
bar(pdf);

Is this correct? Also, I found this function in Matlab pdf() and when I use it as following

p = pdf('Uniform', x);

It gives me NaN. What is wrong?