I have developed matlab code of OFDM index modulation based on look up table but not getting the desired curve...i want curve as shown in link given below on page 5544....somebody plz help me with the coding part...there are many mistakes in my code..plz help me to rectify the code...
https://ieeexplore.ieee.org/abstract/document/6587554
clear all;
close all;
clc;
nsym=10^2;
%nbitspersym=12
bits=(1:12)
n=4
g=2;
%g1=bits(1:6) % division of 16 FFT size into 8 FFT subcarriers.
%g2=bits(7:12) % division of 16 FFT size into 8 FFT subcarriers
ipbits = randi([0,1], 1, 600) % generation of random bits
M=4;
Z=reshape(ipbits,100,6)
k=log2(M)
%n=nFFT/g;
EbN0=1:10
for i1=1:10
EbN0dB=i1
BER=[];
for i=1:100
p1=Z(i,:)
% p1=ipbits(1:6) % it will take first 8 bits
%p1=[1 1 0 1 1 0];
%p2 = ipbits(7:12) ;
s1 = p1(1:2)
s2= p1(3:6)
% s3=p1(5:6);
% s4= p1(7:8);
% s33=s2
s22=reshape(s2,2,2).'
s222=bi2de(s22, 'left-msb')
ipMod = (1/sqrt(2))*qammod(s222 , M)
F=zeros(4,1);
if s1==[0 0]
F(1,1)=ipMod(1)
F(2,1)=ipMod(2)
F(3,1)=0
F(4,1)=0
elseif s1==[0 1]
F(1,1)=0
F(2,1)=ipMod(1)
F(3,1)=ipMod(2)
F(4,1)=0
elseif s1==[1 0]
F(1,1)=0
F(2,1)=ipMod(1)
F(3,1)=0
F(4,1)=ipMod(2)
elseif s1==[1 1]
F(1,1)=ipMod(1)
F(2,1)=0
F(3,1)=0
F(4,1)=ipMod(2)
end
F.'
%=ifft(Sq1,N)*sqrt(N)%
xt=ifft(F).'
%xt=xt.'
xt=[xt(4) xt]
%xt=(nFFT/sqrt(nDSC))*ifft(fftshift(xF.')).';
%x_with_cp = [x(4) x]; % cp addition
% adding noise
nt = (randn + j*randn)./sqrt(2)
yt = xt +( (10.^(-EbN0dB/10)).*nt)
yyt=yt(2:5)
yyt1=fft(yyt)
[temp, idx] = sort( yyt1, 'descend' )
n = temp(1:2)
idx = idx(1:2)
%zzt=(abs(yyt1))
zzt1=(abs(yyt1).^2)
[max1, ind1] = max(zzt1)
zzt1(ind1) = -Inf;
[max2, ind2] = max(zzt1)
zzt1(ind2) = -Inf;
rec=[(ind1) (ind2)]
a1=1;
while(a1==1)
if rec== [1 2]|rec== [2 1]
bitts=[0 0]
a1=0;
elseif rec== [2 3]|rec== [3 2]
bitts=[0 1]
a1=0;
elseif rec== [2 4]| rec== [4 2]
bitts =[1 0]
a1=0;
elseif rec==[4 1]|rec==[1 4]
bitts=[1 1]
a1=0;
elseif rec==[3 1]|rec==[1 3]
BER12=0
break
% bitts=[1 1]
elseif rec==[4 3]|rec==[3 4]
BER12=0
break
% bitts=[0 0]
end
% finding the minimum distance between received vector and original symbols
% original symbols
orig=[0 0]
conv=bi2de(orig, 'left-msb')
ipMod = (1/sqrt(2))*qammod(conv , M)
orig1=[0 1]
conv1=bi2de(orig1, 'left-msb')
ipMod1 = (1/sqrt(2))*qammod(conv1 , M)
orig2=[1 0]
conv2=bi2de(orig2, 'left-msb')
ipMod2 = (1/sqrt(2))*qammod(conv2 , M)
orig3=[1 1]
conv3=bi2de(orig3, 'left-msb')
ipMod3 = (1/sqrt(2))*qammod(conv3 , M)
xxt=[ipMod ipMod1 ipMod2 ipMod3]
D1 =norm(n(1) - xxt(1))
D2 = norm(n(1) - xxt(2))
D3 = norm(n(1) - xxt(3))
D4 = norm(n(1) - xxt(4))
D=[D1 D2 D3 D4]
D5=min(D)
result = find(D==min(D))
DD1 = norm(n(2) - xxt(1))
DD2 = norm(n(2) - xxt(2))
DD3 = norm(n(2) - xxt(3))
DD4 = norm(n(2) - xxt(4))
DD=[DD1 DD2 DD3 DD4]
DD5=min(DD)
result1 = find(DD==min(DD))
G=[DD5 D5]
[tempp, idxx] = sort( G, 'descend' )
nn = tempp(1:2)
idxx = idxx(1:2)
idx1=sort(idxx) % sort according to tempp;
% idx1=[result result1]
%
% reeesult=[result result1 result2 result3]
% [temp1, idx1] = sort( F, 'ascend' )
% n = temp1(1:2)
% idx1 = idx1(1:2)
% [min1, ind1] = min(F)
% F(ind1) = Inf;
% [min2, ind2] = min(F)
% F(ind2) = Inf;
% rec1=[(ind1) (ind2)]
if idx1== [1 2]
biitts=[0 0 0 1]
elseif idx1==[2 1]
message('i m here')
biitts=[ 0 1 0 0]
elseif idx1== [2 3]
message('i m here')
biitts=[0 1 1 0 ]
elseif idx1==[3 2]
message('i m here')
biitts=[ 1 0 0 1 ]
elseif idx1== [2 4]
message('i m here')
biitts =[0 1 1 1]
elseif idx1==[4 2]
message('i m here')
biitts =[1 1 0 1]
elseif idx1==[4 1]
message('i m here')
biitts=[1 1 0 0]
elseif idx1==[1 4]
message('i m here')
biitts=[ 0 0 1 1]
elseif idx1==[3 1]
message('i m here')
biitts=[1 0 0 0]
elseif idx1==[1 3]
message('i m here')
biitts=[0 0 1 0]
elseif G1==[1 1]
biitts=[0 0 0 0]
elseif G1==[2 2]
biitts=[0 1 0 1]
elseif G1==[3 3]
biitts=[1 0 1 0]
elseif G1==[4 4]
biitts=[1 1 1 1]
end
S=[bitts biitts]
% A2 = sort(F(:))
% out=A2(1)
% out1 = A2(2)
% result33 = find(DDDD==min(DDDD))
BER12=sum(abs(p1-S))/6
end
BER=[BER BER12];
end
T_BER(i1)=sum(BER)/100
end
semilogy(EbN0,smooth(abs(T_BER)),'*-');
xlabel('SNR');
ylabel('EbN0dB');
legend('BER curve for OFDM index modulation');