STBC for 2 X 10

Hi everybody please I need your help to implement Large MIMO system using STBC precoding technique. actually, I wrote a code about this scheme but I have no idea where exactly my mistake is? i will be grateful if you can help me either by giving advice on my code or drive me to find the proper code in somewhere else.
the main code
% STBC_3x4_simulation.m clear; clf Lfr=130; N_packet=400; NT=2; NR=10; b=4; M=2^b; SNRdBs=[0:2:30]; sq_NT=sqrt(NT); sq2=sqrt(2); for i_SNR=1:length(SNRdBs) SNRdB=SNRdBs(i_SNR); sigma=sqrt(0.5/(10^(SNRdB/10))); for i_packet=1:N_packet % msg_symbol = randint(Lfr*b,M); msg_symbol=randi([0 1],Lfr*b,NT); tx_bits = msg_symbol.';temp=[]; temp1=[]; for i=1:4 [temp1,sym_tab,P]=modulator(tx_bits(i,:),b); temp=[temp; temp1]; end X=temp.'; %Block signals in the l-th time slot % Block coding for G3 STBC for Tx=3 % X1=X(:,1:3); X5=conj(X1); % X2=[-X(:,2) X(:,1) -X(:,4)]; X6=conj(X2); % should be 20 here % X3=[-X(:,3) X(:,4) X(:,1)]; X7=conj(X3); % X4=[-X(:,4) -X(:,3) X(:,2)]; X8=conj(X4);
%Block signals in the l-th time slot % Block coding for G3 STBC for Tx=2 % X1=X(:,1:2); X10=conj(X1); % X2=[-X(:,2) X(:,1) -X(:,4)]; X11=conj(X2); % should be 20 here % X3=[-X(:,3) X(:,4) X(:,1)]; X12=conj(X3); % X4=[-X(:,4) -X(:,3) X(:,2)]; X13=conj(X4); % % X5=[-X(:,5) -X(:,3) X(:,2)]; X14=conj(X4);
%Block signals in the l-th time slot % Block coding for G3 STBC for Tx=2
X1=X;
X2=[-conj(X(:,2)) conj(X(:,1))];
X3=-conj(X2);
X4=conj(X1);
% for n=1:NT
% for m=1:NR
% Hr(n,:,:)=(randn(NR,NT)+j*randn(NR,NT))/sq2;
% end
% end
% for n=1:NT
% H = reshape(Hr(n,:,:),NR,NT); Hc=conj(H);
% Habs(:,n) = sum(abs(H).^2,2);
for n=1:NT
Hr(n,:,:)=(randn(Lfr,NT)+j*randn(Lfr,NT))/sq2;
end
for n=1:NT
H = reshape(Hr(n,:,:),Lfr,NT); Hc=conj(H);
Habs(:,n) = sum(abs(H).^2,2);
% W= sigma*(randn(NR,1)+j*randn(NR,1));
W=sigma*(randn(Lfr,1)+j*randn(Lfr,1));
%Transmitted Signal*Channel + Noise
R1n = sum(H.*X1,2)/sq_NT +W;
R2n = sum(H.*X2,2)/sq_NT +W;
R3n = sum(H.*X3,2)/sq_NT +W;
R4n = sum(H.*X4,2)/sq_NT +W;
% R3n = sum(H.*X3,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1));
% R4n = sum(H.*X4,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1)); %should be 20
% % R5n = sum(H.*X5,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1));
% % R6n = sum(H.*X6,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1));
% % R7n = sum(H.*X7,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1));
% % R8n = sum(H.*X8,2)/sq_NT +sigma*(randn(Lfr,1)+j*randn(Lfr,1));
% Received Signal % Z1_1 = R1n.*Hc(:,1) + R2n.*Hc(:,2) + R3n.*Hc(:,3); Z1_1 = R1n.*H(:,1) + R2n.*Hc(:,1); % Z1_2 = conj(R5n).*H(:,1) + conj(R6n).*H(:,2) + conj(R7n).*H(:,3); Z1_2 = -conj(R3n).*H(:,1) + conj(R4n).*Hc(:,1); Z(:,n,1)= Z1_1 + Z1_2; % Z2_1 = R1n.*Hc(:,2) - R2n.*Hc(:,1) + R4n.*Hc(:,3); Z2_1 = R1n.*H(:,2) + R2n.*Hc(:,2); % Z2_2 = conj(R5n).*H(:,2) - conj(R6n).*H(:,1) + conj(R8n).*H(:,3); Z2_2 = -conj(R3n).*H(:,2) + conj(R4n).*Hc(:,2); Z(:,n,2) = Z2_1 + Z2_2; % Z3_1 = R1n.*Hc(:,3)- R3n.*Hc(:,1)-R4n.*Hc(:,2); % Z3_2 = conj(R5n).*H(:,3)-conj(R7n).*H(:,1)-conj(R8n).*H(:,2); Z3_1 = R1n.*H(:,1)+ R2n.*Hc(:,2); Z3_2 = conj(R3n).*H(:,1)+conj(R4n).*Hc(:,2); Z(:,n,3) = Z3_1 + Z3_2; % Z4_1 = -R2n.*Hc(:,3) + R3n.*Hc(:,2) - R4n.*Hc(:,1); % Z4_2 = -conj(R6n).*H(:,3) + conj(R7n).*H(:,2)- conj(R8n).*H(:,1); Z4_1 = R1n.*H(:,1) + R2n.*Hc(:,2); Z4_2 = conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z (:,n,4)= Z4_1 + Z4_2; Z5_1 = R1n.*H(:,1) + R2n.*Hc(:,2); Z5_2 =conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z(:,n,5) = Z5_1 + Z5_2; Z6_1 =R1n.*H(:,1) + R2n.*Hc(:,2); Z6_2 =conj(R3n).*H(:,1) + conj(R4n).*H(:,2); Z(:,n,6) = Z6_1 + Z6_2; Z7_1 = R1n.*H(:,1) + R2n.*Hc(:,2); Z7_2 =conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z(:,n,7) = Z7_1 + Z7_2; Z8_1 =R1n.*H(:,1) + R2n.*Hc(:,2); Z8_2 =conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z(:,n,8) = Z8_1 + Z8_2; Z9_1 = R1n.*H(:,1) + R2n.*Hc(:,2); Z9_2 =conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z(:,n,9) = Z9_1 + Z9_2; Z10_1 = R1n.*H(:,1) + R2n.*Hc(:,2); Z10_2 =conj(R3n).*H(:,1) + conj(R4n).*Hc(:,2); Z(:,n,10) = Z10_1 + Z10_2; end for m=1:P tmp = (-1+sum(Habs,2))*abs(sym_tab(m))^2; for i=1:4 d(:,m,i) = abs(sum(Z(:,:,i),2)-sym_tab(m)).^2 + tmp; end end Xd = []; for n=1:4, [yn,in]=min(d(:,:,n),[],2); Xd=[Xd sym_tab(in).']; end temp1=X>0; temp2=Xd>0; noeb_p(i_packet) = sum(sum(temp1~=temp2)); end % End of FOR loop for i_packet BER(i_SNR) = sum(noeb_p)/(N_packet*Lfr*b); end % End of FOR loop for i_SNR semilogy(SNRdBs,BER), axis([SNRdBs([1 end]) 1e-6 1e0]) grid on legend('sim (nTx=2, nRx=10, Alamouti)'); xlabel('Eb/No, dB'); ylabel('Bit Error Rate'); title('BER for 16-QAM modulation with 2Tx, 10Rx Alamouti STBC (Rayleigh channel)');
the modulation function
function [mod_symbols,sym_table,M] = modulator(bitseq,b)
%MIMO-OFDM Wireless Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim, Won Young Yang and Chung G. Kang %2010 John Wiley & Sons (Asia) Pte Ltd
N_bits = length(bitseq); if b==1 % BPSK modulation sym_table=exp(j*[0 -pi]); sym_table=sym_table([1 0]+1); inp=bitseq; mod_symbols=sym_table(inp+1); M=2; elseif b==2 % QPSK modulation sym_table = exp(j*pi/4*[-3 3 1 -1]); sym_table=sym_table([0 1 3 2]+1); inp=reshape(bitseq,b,N_bits/b); mod_symbols=sym_table([2 1]*inp+1); M=4; elseif b==3 % generates 8PSK symbols sym_table=exp(j*pi/4*[0:7]); sym_table=sym_table([0 1 3 2 6 7 5 4]+1); inp=reshape(bitseq,b,N_bits/b); mod_symbols=sym_table([4 2 1]*inp+1); M=8; elseif b==4 % 16-QAM modulation m=0; sq10=sqrt(10); for k=-3:2:3 for l=-3:2:3 m=m+1; sym_table(m) = (k+j*l)/sq10; % power normalization end end sym_table = sym_table([0 1 3 2 4 5 7 6 12 13 15 14 8 9 11 10]+1); % Gray code mapping pattern for 8-PSK symbols inp = reshape(bitseq,b,N_bits/b); mod_symbols = sym_table([8 4 2 1]*inp+1); % maps transmitted bits into 16QAM symbols M=16; %16 constellation points else error('Unimplemented modulation'); end

2 Comments

dpb
dpb on 18 Aug 2013
Edited: dpb on 18 Aug 2013
After which reformatting, trim to the minimum to explain the specific problem; don't expect somebody else to have any clue as to what you might thing is wrong or to do your debugging/code development for you. They are likely to help w/ specific implementation details, etc., given some guidance as to what is the problem.
You might start by defining "STBC"...

Sign in to comment.

Answers (0)

Tags

Asked:

on 18 Aug 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!