smldp511.m

来自「详细介绍了cdma通信系统功率控制的算法」· M 代码 · 共 55 行

M
55
字号
function [p]=smldP511(snr_in_dB)% [p]=smldP511(snr_in_dB)%		SMLDP511  simulates the probability of error for the given%   		snr_in_dB, signal to noise ratio in dB, for the system %   		described in illustrated problem 11, Chapter 5.M=4;				   	% quarternary orthogonal signallingE=1;SNR=exp(snr_in_dB*log(10)/10);	   	% signal to noise ratio per bitsgma=sqrt(E^2/(4*SNR));  	   	% sigma, standard deviation of noiseN=10000;	 		   	% number of symbols being simulated% generation of the quarternary data sourcefor i=1:N,   temp=rand;   	      		% uniform random variable over (0,1)   if (temp<0.25),      dsource(i)=0;    elseif (temp<0.5),      dsource(i)=1;    elseif (temp<0.75),      dsource(i)=2;    else      dsource(i)=3;    endend;% detection, and error probability computationnumoferr=0;for i=1:N,   % The matched filter outputs   if (dsource(i)==0)      r0=sqrt(E)+gngauss(sgma);      r1=gngauss(sgma);   elseif (dsource(i)==1)      r0=gngauss(sgma);      r1=sqrt(E)+gngauss(sgma);   elseif (dsource(i)==2)      r0=-sqrt(E)+gngauss(sgma);      r1=gngauss(sgma);   else      r0=gngauss(sgma);      r1=-sqrt(E)+gngauss(sgma);   end;   % detector follows   if (r0>abs(r1)),      decis=0;   elseif (r1>abs(r0)),      decis=1;   elseif (r0<-abs(r1)),      decis=2;   else      decis=3;   end;   if (decis~=dsource(i)),     		% if it is an error, increase to the error counter      numoferr=numoferr+1;   end;end;p=numoferr/N;	               		% bit error probability estimate

⌨️ 快捷键说明

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