Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Matlab Code for PSK Demodulator

# Matlab Code for PSK Demodulator

Ratings: (0)|Views: 1,404|Likes:

Categories:Types, School Work

### Availability:

See more
See less

07/14/2013

pdf

text

original

% ----------------------------------------

% +++++ Simulation of PSK Demodulator +++++++

% For simplicity only the detector (after sampling) is simulated.

% ----------------------------------------clearall; closeall;

E = 1 ;% normalized to unit energy

snr_dB = 20 ;

N = 10000 ;% no of bits ...

M = 8 ;% no. of levels ...

phi = 0*pi/180 ;% carrier phase off-set in radian ..

snr = exp(snr_dB*log(10)/10) ;

sig = E/sqrt(2*snr) ;% this is detector noise std deviation

% the detector signals and symbol error ....

err = 0 ;

fori=1:N

tt = rand;% tt is uniformly distributed in 0->1 .

src = floor(rand*M) ;% simulate symbols 0 -- M-1 ....

r0(i) = cos(phi+2*pi*src/M) + sig*randn ;% WGNr1(i) = sin(phi+2*pi*src/M) + sig*randn ;

ang = atan2(r1(i),r0(i)) ;

if(ang < 0)

ang = ang + 2*pi ;% angle in 0 --> 2*pi

end;

det = round(M*ang/(2*pi)) ;

if(det == M )det = 0 ;

end;

if(det ~= src)err = err + 1 ;

end;

end;

SER = err/N ;

% calculte therotical BER ...in a SNR (db) range

dbR = 0:1:20 ;

fori = 1:length(dbR)

snr = exp(dbR(i)*log(10)/10) ;

SERT(i) = erfc(sqrt(snr)*sin(pi/M)) ;

end;

figure(1); plot(r0,r1,'.');

holdon;fork=1:M

plot([0 2*cos((2*k-1)*pi/M)], [0 2*sin((2*k-1)*pi/M)],'r--') ;end;

holdoff;

axis([-1.5 1.5 -1.5 1.5]);grid;

title('Signal constellations (normalized by Energy)');

xlabel('real part');