⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psk.m

📁 this file contain some useful common communication matlab m tool. like QAM PSK and simulation of rec
💻 M
字号:
%          ----------------------------------------
%  +++++    Simulation of PSK Demodulator     +++++++
%  For simplicity only the detector (after sampling) is simulated.
%          ----------------------------------------   
clear all ; close all;

E = 1 ;       % normalized to unit energy
snr_dB = 25 ;

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) ;%w-change snr-dB to snr
sig = E/sqrt(2*snr) ;       % this is detector noise std deviation

% the detector signals and symbol error ....
err = 0 ;
for i=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 ;  % WGN 
   r1(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 ;
for i = 1:length(dbR)
   snr = exp(dbR(i)*log(10)/10) ;
   SERT(i) = erfc(sqrt(snr)*sin(pi/M)) ;
end ;

figure(1); plot(r0,r1,'.');
hold on ; 
for k=1:M
 plot([0 2*cos((2*k-1)*pi/M)], [0 2*sin((2*k-1)*pi/M)],'r--') ; 
end ;
hold off ;
axis([-1.5 1.5 -1.5 1.5]); 
grid;
title('Signal constellations (normalized by Energy)');
xlabel('real part');
ylabel('imaginary part');
figure(2); semilogy(dbR, SERT, snr_dB, SER,'r*') ; 
grid ;
xlabel('SNR in dB');
ylabel('Symbol Error Probability, Pm');
title('Theoretical (blue) and simulated (red *) Pm');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -