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

📄 ortho_rec.m

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

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

N = 10000 ;    % no of bits  ...
% simulate the source bits 0 or 1 ....
for i=1:N
   tt = rand;   %  tt is uniformly distributed in 0->1 .
   if (rand < 0.5)
      src(i) = 0 ;
   else
      src(i) = 1 ;
   end
end ;

% simulate the noise for each correlator ..
snr = exp(snr_dB*log(10)/10) ;
sig = E/sqrt(2*snr) ;       % this is detector noise std deviation

% the detector signals and BER ....
err = 0 ;
for i=1:N
   n0 = sig*randn ;  % WGN 
   n1 = sig*randn ;

   if(src(i) == 0)
      r0(i) = E + n0 ;
      r1(i) =     n1 ;
   else
      r0(i) =     n0 ;
      r1(i) = E + n1 ;
   end 
   if (r0(i) > r1(i))        % this is the detection
      bit = 0 ;
   else 
      bit = 1 ;
   end
   if (bit ~= src(i))
      err = err + 1 ;
   end ;
end;
BER = 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) ;%w signal noise rato
   BERT(i) = 0.5*erfc(sqrt(snr/2)) ;
end ;

figure(1); plot(r0,r1,'.', [0 1.5], [0 1.5],'r--') ; 
axis([-0.5 1.5 -0.5 1.5]); 
grid;
title('Signal constellations (normalized by Energy)');
xlabel('correlator-0 output');
ylabel('correlator-1 output');
figure(2); semilogy(dbR, BERT, snr_dB, BER,'r*') ; 
grid ;
xlabel('SNR in dB');
ylabel('Bit Error Probability, Pb');
title('Theoretical (blue) and simulated (red *) Pb');

[h,m] = hist(r0,30);
figure(3) ; plot(m,h/N,'r--') ; grid ;
xlabel('Normalized output');
ylabel('Probability density');
title('Histogram for correlator-0 output');

⌨️ 快捷键说明

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