-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathAlamouti_16QAM.m
50 lines (34 loc) · 1.2 KB
/
Alamouti_16QAM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
clc
clear
close all
M=16; %PSK order (must be a power of 2): 2, 4, 8 etc'
Tx=2; %number of Tx elements, must be 2
Rx=1; %number of Rx elements
SNR=0:2:22; %SNR in dB, average received power at one Rx element over the average noise power at that element
for k=1:length(SNR)
SNR(k)
N=5000;
A=floor(M*rand(2,N)); %transmitted alphabet
st = qammod(A,M, 'UnitAveragePower', true);
snr=10^(SNR(k)/10);
sig1=0.5/snr ; %the sigma square of the noise
Ns=sqrt(sig1)*(randn(2*Rx,N)+j*randn(2*Rx,N)); %noise matrix
%Transceiver
for n=1:N
H=[]; %equivalent channel matrix initialization
for r=1:Rx
h=(randn(1,2)+j*randn(1,2))/sqrt(2); %Rayleigh channel
H=[H; h(1) h(2); h(2)' -h(1)'];
end %m
sr(:,n)=H'*H*st(:,n)+H'*Ns(:,n); %received symbols
temp = H'*H;
sr(:,n) = sr(:,n)/temp(1,1);
end %n
decoded = qamdemod(sr, M,'UnitAveragePower',true );
temp = xor(A-decoded, 0);
temp = sum(temp);
temp(temp>1)=1;
ser(:, k) =sum(temp)/N;
end %k (SNR)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
semilogy(0:2:22,ser)