📄 almouti2x2.m
字号:
clc;
clear all;
close all;
clf;
no_bit=input('Enter the no. of bits generated ');
actual_data=randint(1,no_bit);
in_data=2*actual_data-1; %bpsk mapping
linColor = 'b';
linSym1 = 'o';
linSym2 = 'x';
SNRdB = 1:1:25;
% Memory allocation
errRate = zeros(size(SNRdB));
%% Alamouti Space Time Code
for i = 1 : length(SNRdB)
% Main Program
% generating the data
% splitting the data into two vectors (first transmition, second
% transmition in time);
actual_data=randint(1,no_bit);
in_data=2*actual_data-1; %bpsk mapping
temp = reshape(in_data,2,no_bit/2);
H = [randn(2,no_bit)] + [sqrt(-1)*randn(2,no_bit)];
% transmitted data through channel
Hoverall=[];
Hnew=[];
for j=1:no_bit/2;
txMod(1,j)=H(1,2*j-1)*temp(1,j)+H(1,2*j)*temp(2,j);
txMod(2,j)=H(2,2*j-1)*temp(1,j)+H(2,2*j)*temp(2,j);
txMod(3,j)=conj(H(1,2*j))*temp(1,j)-conj(H(1,2*j-1))*temp(2,j);
txMod(4,j)=conj(H(2,2*j))*temp(1,j)-conj(H(2,2*j-1))*temp(2,j);
Hnew=[H(1,2*j-1) H(1,2*j);H(2,2*j-1) H(2,2*j);conj(H(1,2*j)) -conj(H(1,2*j-1)); conj(H(2,2*j)) -conj(H(2,2*j-1))];
Hoverall=[Hoverall Hnew];
[U,S,V]=svd(Hnew);
end
% adding noise
txMod = awgn(txMod,SNRdB(i),'measured');
% receiving the data
for j=1:no_bit/2;
[U,S,V]=svd(Hoverall(1:4,(2*j-1):(2*j)));
p=U^(-1)*txMod(:,j)
S1=S(1:2,:)^(-1)*p(1:2,:);
S2=(V')^(-1)*S1;
data(1,j)=S2(1,1);
data(2,j)=S2(2,1);
end
data=real(data);
for j=1:length(data(1,:))
if(data(1,j)>0)
data(1,j)=1;
else
data(1,j)=-1;
end
if(data(2,j)>0)
data(2,j)=1;
else
data(2,j)=-1;
end
end
rxData=data;
[numErr errRate(i)] = symerr(rxData,reshape(in_data,2,no_bit/2));
end
f1 = figure(1);
semilogy(SNRdB,errRate,[linColor,'-',linSym1]);
xlabel('SNR in dB');
ylabel('Symbol Error Rate');
% Without Almouti coding
for i = 1 : length(SNRdB)
actual_data=randint(1,no_bit);
in_data=2*actual_data-1; %bpsk mapping
temp = reshape(in_data,no_bit/2,2);
% Channel Definition
H = 1/sqrt(2) * (randn(no_bit/2,2) + sqrt(-1)*randn(no_bit/2,2));
% passing through channel
txMod = H.*temp;
% adding noise
txMod = awgn(txMod,SNRdB(i),'measured');
% decoding
temp = txMod./H;
temp=real(temp);
for j=1:length(temp(:,1))
if(temp(j,1)>0)
temp(j,1)=1;
else
temp(j,1)=-1;
end
if(temp(j,2)>0)
temp(j,2)=1;
else
temp(j,2)=-1;
end
end
rxData = temp;
[numErr errRate(i)] = symerr(rxData,reshape(in_data,no_bit/2,2));
end
figure(1);
hold on
semilogy(SNRdB,errRate,[linColor,':',linSym2]);
xlabel('SNR in dB');
ylabel('Symbol Error Rate');
title(['SER evaluation of BPSK Modulation based on Alamouti STC'])
legend('With Alamouti Coding','Without Almouti coding(2X2)')
grid on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -