pr2_46.m

来自「Spread Spectrum and CDMA Principles and 」· M 代码 · 共 12 行

M
12
字号
%Problem 2.46;
%Binary transmission error probability;
%Calculates error probability for an arbitrary signal pair versus SNR.
clear all; 
SP=[ones(1,100);ones(1,50),-ones(1,50);ones(1,70),-ones(1,30);zeros(1,100)]; %gives signal waveforms used further, one can add any wished signals;
S=[zeros(2,10),[SP(1,:);-SP(1,:)],zeros(2,10)]; %selects a pair of signals and appends front and end zeros to better visualize them;
N=size(S,2); E1=norm(S(1,:))^2; E2=norm(S(2,:))^2; %defines dimension and energies of signals;
subplot(121); plot(S');grid; xlabel('t'); ylabel('signals'); ylim([-1.2 1.2]); xlim([0,120]); %plotting signals
SNR=[1:0.1:5]; %SNR array;
x=(SNR.^2)*(1-2*(S(1,:)*S(2,:)')/(E1+E2))/2; %argument for error probability according to (2.16);
BER=erfc(sqrt(x/2))/2; %error probability (2.18);
subplot(122); plot(20*log10(SNR),log10(BER));grid; xlabel('SNR, dB'); ylabel('Error probability'); %plotting error probability;

⌨️ 快捷键说明

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