MATLAB: Plot normal distribution with unknown mean that is normally distributed with known parameters

normal distributionplot

How can I use Matlab to plot a univariate normal distribution when it has unknown mean but the mean is also normally distributed with known mean of mean and variance of mean?
Eg. N(mean, 4) and mean ~N(2,8)

Best Answer

2 + 8*randn(1, 100) + 4*randn(100,1);
or in more detail
n = 1; m = 100; % number of samples
m1 = 2; s1 = 8; s2 = 4;
m2 = m1 + s1*rand(n, m);
X = m2 + s2*rand(n, m);