Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to generate AWGN using randn

Status
Not open for further replies.

nigosawa

Junior Member level 1
Junior Member level 1
Joined
Dec 21, 2006
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,434
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
 

AWGN

Hi,

just replace "plot(x,px);" instead of "plot(px)".

regards
 

    nigosawa

    Points: 2
    Helpful Answer Positive Rating
Re: AWGN

thnx alot mahdithdn
u know i have been trying this for days and couldnt see this small mistake in my code

thnx once again man
u have helped me several times
god bless ya
cheers
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top