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

📄 cm_sm41.m

📁 contemporarycommunicatonsystem-using MATLAB经典书目源程序!
💻 M
字号:
function [p]=cm_sm41(snr_in_dB)% [p]=cm_sm41(snr_in_dB)%		CM_SM41  finds the probability of error for the given%   		value of snr_in_dB, SNR in dB.N=10000;d=1;				  	% min. distance between symbolsEav=10*d^2;		 	  	% energy per symbolsnr=10^(snr_in_dB/10);	 	  	% SNR per bit (given)sgma=sqrt(Eav/(8*snr));	  	  	% noise varianceM=16;% generation of the data source followsfor i=1:N,	  temp=rand;			  	% a uniform R.V. between 0 and 1  dsource(i)=1+floor(M*temp);	  	% a number between 1 and 16, uniform end;% Mapping to the signal constellation followmapping=[-3*d 3*d;	   -d  3*d;            d  3*d;	  3*d  3*d;	 -3*d  d;	   -d  d;	    d  d;	  3*d  d; 	 -3*d  -d; 	   -d  -d; 	    d  -d;          3*d  -d;	 -3*d  -3*d;	   -d  -3*d;	    d  -3*d;	  3*d  -3*d];for i=1:N,  qam_sig(i,:)=mapping(dsource(i),:);end;% received signalfor i=1:N,  [n(1) n(2)]=gngauss(sgma);  r(i,:)=qam_sig(i,:)+n;end;% detection and error probability calculationnumoferr=0;for i=1:N,  % metric computation follow  for j=1:M,    metrics(j)=(r(i,1)-mapping(j,1))^2+(r(i,2)-mapping(j,2))^2;  end;  [min_metric decis] = min(metrics);  if (decis~=dsource(i)),    numoferr=numoferr+1;  end;end;p=numoferr/(N);		  

⌨️ 快捷键说明

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