iamsamriti
Newbie level 4
can someone please share the Bit error rate code of basic OFDM- index modulation on my mail id MODERATOR ACTION: email address is removed
Last edited by a moderator:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
can someone please share the Bit error rate code of basic OFDM- index modulation on my mail id MODERATOR ACTION: email address is removed
What programming language would you like your code to be in?
How would you like your bits to be mapped to symbols? (e.g. QAM, PSK, etc).
I don't think many researchers are interested in index modulation, so it might be advisable to start with standard OFDM, then modify your code for index modulation.
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]
%
% [~, F] = sort(idx1)
% F = F(1:2)
% D1 = norm(yyt1(1) - xxt(1))
% D2 = norm(yyt1(1) - xxt(2))
% D3 = norm(yyt1(1) - xxt(3))
% D4 = norm(yyt1(1) - xxt(4))
% D=[D1 D2 D3 D4]
% D5=min(D)
% result = find(D==min(D))
%
%
% DD1 = norm(yyt1(2) - xxt(1))
% DD2 = norm(yyt1(2) - xxt(2))
% DD3 = norm(yyt1(2) - xxt(3))
% DD4 = norm(yyt1(2) - xxt(4))
% DD=[DD1 DD2 DD3 DD4]
% DD5=min(DD)
% result1 = find(DD==min(DD))
%
%
% DDD1 = norm(yyt1(3) - xxt(1))
% DDD2 = norm(yyt1(3) - xxt(2))
% DDD3 = norm(yyt1(3) - xxt(3))
% DDD4 = norm(yyt1(3) - xxt(4))
% DDD=[DDD1 DDD2 DDD3 DDD4]
% DDD5=min(DDD)
% result2 = find(DDD==min(DDD))
%
% DDDD1 = norm(yyt1(4) - xxt(1))
% DDDD2 = norm(yyt1(4) - xxt(2))
% DDDD3 = norm(yyt1(4) - xxt(3))
% DDDD4 = norm(yyt1(4) - xxt(4))
% DDDD=[DDDD1 DDDD2 DDDD3 DDDD4]
% DDDD5=min(DDDD)
% result3 = find(DDDD==min(DDDD))
%
% F=[D5 DD5 DDD5 DDDD5]
% 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');