📄 maxunite.m
字号:
close all;
clear all;
randn('state',sum(100*clock)); %reset the randn generator
A=1;
Es=A*A;
myCst=A*[j,1,-1,-j]; %the constellation
Eb=2*Es;
for EbN0=0:1:10
N0=Eb*10^(-EbN0/10);
noiseRoot=sqrt(N0/2);
errorCount=0;
testCount=0;
while(1)
% Generate the Rayleigh fading channel
h0=(randn(1)+j*randn(1))*sqrt(0.5);
h1=(randn(1)+j*randn(1))*sqrt(0.5);
h2=(randn(1)+j*randn(1))*sqrt(0.5);
h3=(randn(1)+j*randn(1))*sqrt(0.5);
%Noise generator
n0=(randn(1)+j*randn(1))*noiseRoot;
n1=(randn(1)+j*randn(1))*noiseRoot;
n2=(randn(1)+j*randn(1))*noiseRoot;
n3=(randn(1)+j*randn(1))*noiseRoot;
%Binary source
src=randn(1,4)>0; %binary source with equal probability
x=modulate(src); %'0' maps to -A, '1' maps to A
%Simulate the MIMO channel with noise
S0=x(1);
S1=x(2);
r0=h0*S0+h1*S1+n0;
r1=-h0*conj(S1)+h1*conj(S0)+n1;
r2=h2*S0+h3*S1+n2;
r3=-h2*conj(S1)+h3*conj(S0)+n3;
%MRC receiver
S0_MRC=conj(h0)*r0+h1*conj(r1)+conj(h2)*r2+h3*conj(r3);
S1_MRC=conj(h1)*r0-h0*conj(r1)+conj(h3)*r2-h2*conj(r3);
%Decision
decision_code=[S0_MRC S1_MRC];
dst=demodulate(decision_code);
err=xor(src,dst);
errorCount=errorCount+sum(err);
testCount=testCount+4;
m=errorCount/testCount
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -