MATLAB Code for OFDM Using Convolutional coding

OFDM is simply defined as a form of multi-carrier modulation where the carrier spacing is carefully selected so that each sub carrier is orthogonal to the other sub carriers. Two signals are orthogonal if their dot product is zero That is, if you take two signals multiply them together and if their integral over an interval is zero, then two signals are orthogonal in that interval. OFDM is an optimal version of multicarrier transmission schemes. For a large number of sub channels, the arrays of sinusoidal generators and coherent demodulators required in a parallel system become unreasonably expensive and complex. The receiver needs precise phasing of the demodulating carriers and sampling times in order to keep crosstalk between sub channels acceptable. 
clear all
close all
clc
Mt=2;Mr=2;%the number of transmit and received antennas 
N=64;   %the number of subcarrier
nos=200;%number of symbol
P=3;   %length of CP
M=N+P;  %the totle length of an OFDM symbol
J=2;    %collect J consecutively received OFDM symbols
L=3;    %the order of channel
Nm=1;
h11=[-0.049+j*0.359 0.482-j*0.569 -0.556+j*0.587 1];
h12=[0.443-j*0.0364 1 0.921-j*0.194 0.189-j*0.208 ];
h21=[0.221-j*0.322 -0.199+j*0.918 1 0.284-j*0.524 ];
h22=[0.417+j*0.030 1 0.873+j*0.145 -0.285+j*0.309 ];
h1=[-0.049+j*0.359 0.443-j*0.0364;0.221-j*0.322 0.417+j*0.030];
h2=[0.482-j*0.569 1;-0.199+j*0.918 1];
h3=[-0.556+j*0.587 0.921-j*0.194;1 0.873+j*0.145];
h4=[1 0.189-j*0.208;0.284-j*0.524 -0.285+j*0.309 ];
H=[h1 h2 h3 h4];
%HH=[-0.049+j*0.359 0.221-j*0.322  0.482-j*0.569 -0.199+j*0.918 -0.556+j*0.587 1 1 0.284-j*0.524 0.443-j*0.0364 0.417+j*0.030 1 1 0.921-j*0.194 0.873+j*0.145 0.189-j*0.208 -0.285+j*0.309].';
HH=[h1.' h2.' h3.' h4.'].';
%%%%%%%%%%H=h(:);%
%H1
H1=zeros((J*M-L)*Mr,J*M*Mt);
H1(1:Mr,:)=[H zeros(Mr,(J*M-L-1)*Mt)];
for i=1:J*M-L-1
htmp=H1((i-1)*Mr+1:i*Mr,:);
    H1(i*Mr+1:(i+1)*Mr,:)=[htmp(:,(J*M-1)*Mt+1:J*M*Mt),htmp(:,1:(J*M-1)*Mt)];
end
%H1?
NRMSE=zeros(1,9);SNR=[];a=[];
SNR1=0:5:50;
forsnr=0:5:50
     Herr=0;
for i1=1:Nm
Rr=zeros((J*M-L)*Mr,(J*M-L)*Mr);
        %-----------------------------------------%
        b0=round(rand(1,Mt*2*N*nos));
        b=zeros(1,N*nos);
        b1=reshape(b0,2,Mt*N*nos).';
        b2=bi2de(b1,2,'left-msb');
        b3=[1+j 1-j -1+j -1-j];
        b=b3(b2+1)/sqrt(2);%1*12800;
        %
        d1=b(:);
for i=1:nos-J+1
d4(:,i)=d1((i-1)*N*Mt+1:(i+J-1)*N*Mt);
end
j=sqrt(-1);
W1=zeros(N,N);
for i1=1:N
for j1=1:N
W1(j1,i1)=exp(j*2*pi*(N-i1)*(j1-1)/N)/sqrt(N);
end
end
W=[W1,W1(:,1:P)].';
Ij=eye(J);%
Imt=eye(Mt);
W2=kron(Ij,W);
W3=kron(W2,Imt);%
W4=conj(W)*(W.');%
A=kron(Ij,W4);
          s=W3*d4;
          r1=H1*s;
          n=rand(size(r1))+sqrt(-1)*rand(size(r1));
         
          SNR=[SNR 20*log10(norm(r1))/norm(n)];
          r=r1+n;%
Rr=r*r'/(nos-J+1); %?(J*M-L)*(J*M-L);
           %
          [U0,S0,V0]=svd(Rr);
          %
          Q=zeros((L+1)*Mr,(L+1)*Mr);
for k=J*N*Mt+1:(J*M-L)*Mr%
uk=U0(:,k);%256~262;
              vk1=reshape(uk,Mr,J*M-L);%2*131?
vk=zeros((L+1)*Mr,J*M);%
vk(1:Mr,:)=[vk1 zeros(Mr,L)];%1*180?
for i3=1:L
vktmp=vk((i3-1)*Mr+1:i3*Mr,:);
vk(i3*Mr+1:(i3+1)*Mr,:)=[vktmp(:,J*M) vktmp(:,1:J*M-1)];
end
              Q=Q+vk*A*vk';%vk;???8*8?
end
          [U1 S1 V1]=svd(Q);
          hr0=U1(:,(L+1)*Mr-Mt+1:(L+1)*Mr);
hb_h=mean(hr0./HH);
hb=hr0/hb_h;
          HA=hr0(:,1)./hb_h(:,1);
         HB=hr0(:,2)./hb_h(:,2);
hb=[HA HB];
          Herr1=HH-hb;
for i4=1:Mt
              Herr=Herr+(norm(Herr1(:,i4)))^2/(norm(H(:,i4)))^2;
end
end

figure(1)
te=length(H); 
    plot(1:te,real(H),'ko-',1:te,real(hb),'k+-')
legend('Estimated','Accurate')
figure(2)
    plot(1:te,imag(H),'ko-',1:te,imag(hb),'k+-')
legend('Estimated','Accurate')
figure(3)
semilogy(SNR1,'-*')
xlabel('SNR/dB');ylabel('NRMSE');grid on;

Contact:  
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Contact Us

Name

Email *

Message *

Blog Archive

Blog Archive

Popular posts