smldpe54.m

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

M
39
字号
function [p]=smldPe54(snr_in_dB)% [p]=smldPe54(snr_in_dB)%		SMLDPE54  finds the probability of error for the given%   		snr_in_dB, signal to noise ratio in dB.E=1;SNR=exp(snr_in_dB*log(10)/10);	   	% signal to noise ratiosgma=E/sqrt(2*SNR);		   	% sigma, standard deviation of noiseN=10000;% generation of the binary data sourcefor i=1:N,  temp=rand;   	      			% a uniform random variable over (0,1)  if (temp<0.5),    dsource(i)=0;   	      		% with probability 1/2, source output is 0  else    dsource(i)=1;	      		% with probability 1/2, source output is 1  endend;% detection, and probability of error calculation numoferr=0;for i=1:N,  % matched filter outputs  if (dsource(i)==0),    r0=E+gngauss(sgma);    r1=gngauss(sgma);	      		% if the source output is "0"  else    r0=gngauss(sgma);    r1=E+gngauss(sgma);     		% if the source output is "1"  end;  % detector follows  if (r0>r1),    decis=0;		      		% decision is "0"   else    decis=1;		      		% decision is "1"   end;  if (decis~=dsource(i)),    		% if it is an error, increase the error counter    numoferr=numoferr+1;  end;end;p=numoferr/N;	  	      		% probability of error estimate

⌨️ 快捷键说明

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