Sie sind auf Seite 1von 2

Almouti16QAM2X1.

m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% Alamouti Code for 2-transmiters and 1-receiver %%%%%%%%%
%%%%%%%%%%%%%%%%%%% 16-QAM %%%%%%%%%%%%%%%%%%
clc
clear all;
close all;
N = 10^5;
snr=linspace(0,25,26);
M=16;%M-ary Constellation
x = randint(N,1,M);
y1=modulate(modem.qammod(M),x);
y1=reshape(y1,1,N);
y = zeros(2,N);
y(:,1:2:end) = reshape(y1,2,N/2); % [x1 x2; ...]
y(:,2:2:end) =(kron(ones(1,N/2),[-1;1]).*flipud(reshape(conj(y1),2,N/2)));% [-x2* x1*;
....]
h1 = 1/sqrt(2)*(randn(1,N/2) + 1i*randn(1,N/2));
h2 = 1/sqrt(2)*(randn(1,N/2) + 1i*randn(1,N/2));
h=[h1;h2];
H = kron(h,ones(1,2));
hEq = zeros(2,N);
hEq(:,(1:2:end)) = reshape(h,2,N/2); % [h1 0 ... ; h2 0...]
hEq(:,(2:2:end)) = kron(ones(1,N/2),[1;-1]).*flipud(reshape(h,2,N/2)); % [h1 h2 ..; h2
-h1..]
hEq(1,:) = conj(hEq(1,:)); % [h1* h2* ... ; h2 -h1 .... ]
hEqPower = sum(hEq.*conj(hEq),1);% mod(h1)^2+mod(h2)^2

ser=length(snr);
th=[];
for i=1:length(snr)
n=1/sqrt(2)*(randn(1,N)+1i*randn(1,N));% AWGN Noise vector
y3=sum(H.*y,1)+10^(-(snr(i)-10*log10(20))/20)*n;%snr is in dB
% Scaling w.r.t Transmitted power and divided by Avg Constellation Power
% Avg Constellation power is 10 for 16 QAM and each Transmitter power is P/2
% so subtract snr by 10*2=20
yMod = kron(reshape(y3,2,N/2),ones(1,2)); % [y1 y1 ... ; y2 y2 ...]
yMod(2,:) = conj(yMod(2,:)); % [y1 y1 ... ; y2* y2*...]
yHat = sum(hEq.*yMod,1)./hEqPower; % [h1*y1 + h2y2*, h2*y1 -h1y2*, ... ]
z=qamdemod(yHat,M);%Qam Demodulation
z=reshape(z,N,1);
[num ty]=symerr(x,z);%findind Symbol error rate
ser(i)=ty;
end
semilogy(snr,ser,'r-*');grid on;hold on;
title('Plot of symbol error rates for Alamouti nTx=2, nRx=1, for 16QAM','Color','k','FontSize',13);
legend('sim (nTx=2, nRx=1, Alamouti(16-QAM))');
xlabel('SNR(dB) ---->','FontSize',11);Ylabel('Symbol Error Rate ---->','FontSize',11);