nigosawa
Junior Member level 1
hey guys
i saw a similar post few days back in this forum. i m facing the same prob
i m told to generate AWGN and then plot its pdf
when i generate it by randn(setting mean=0 variance=1) i get normally distributed sequence of numbers. then i sort them using sort function. but when i plot them i dont get a bell shaped curve.
if instead of randn i use rand function(which produces numbers uniformly distributed) and then plots it pdf, then i get a bell shaped curve.
i asked teacher if i could use rand instead of randn, he said no kuz then purpose of gaussian noise fails.
so help me out how to do it
below is the code i use
x1=randn(1,10000);
m=mean(x1)
s_d=std(x1)
x=sort(x1);
%px=(exp(-((x-m).^2)/(2*s_d*s_d)))/(sqrt(2*pi)*s_d); %pdf formula
px=normpdf(x,0,1); %pdf formula
plot(px);
here i the second last line and line before second last one, i have used two ways of calculating pdf. anyone can be used and the other can be left commented
i saw a similar post few days back in this forum. i m facing the same prob
i m told to generate AWGN and then plot its pdf
when i generate it by randn(setting mean=0 variance=1) i get normally distributed sequence of numbers. then i sort them using sort function. but when i plot them i dont get a bell shaped curve.
if instead of randn i use rand function(which produces numbers uniformly distributed) and then plots it pdf, then i get a bell shaped curve.
i asked teacher if i could use rand instead of randn, he said no kuz then purpose of gaussian noise fails.
so help me out how to do it
below is the code i use
x1=randn(1,10000);
m=mean(x1)
s_d=std(x1)
x=sort(x1);
%px=(exp(-((x-m).^2)/(2*s_d*s_d)))/(sqrt(2*pi)*s_d); %pdf formula
px=normpdf(x,0,1); %pdf formula
plot(px);
here i the second last line and line before second last one, i have used two ways of calculating pdf. anyone can be used and the other can be left commented