How to calculate BER vs. SNR in ACO-OFDM system over VLC channel?

17 views (last 30 days)
I am trying to calculate BER vs. SNR performance of LS and MMSE aided channel estimation algorithms in ACO-OFDM system over VLC channel in order to get the result like in the figure below
but unfortunately, I always find an error in calculation for example the error below
Error using modulate
Not enough input arguments.
any assitance please?
clear all;
close all;
m = 512;
N = 1024;
M = 4;
pilotFrequency = 8;
E = 2;
Ncp = 256;
Data=randi([0 M-1],m,N);
Tx = qammod(Data,M);
Rx = qamdemod(Data,M);
for k1 = 1:m
for m1=1:N
if mod(m1,2)==0
Data(k1,m1)=0;
end
end
end
DataMod = modulate(Tx,Data);
DataMod_serialtoparallel = DataMod.';
PLoc = 1 : pilotFrequency: N;
DLoc=setxor(1:N, PLoc);
DataMod_serialtoparallel(PLoc,:)= E*DataMod_serialtoparallel(PLoc,:);
datamat=DataMod_serialtoparallel;
datamat(1,:)=0;
datamat(513,:)=0;
datamat(514:1024,:)=flipud(conj(datamat(2:512,:)));
d_ifft=ifft((datamat));
for k2=1:N
for m2=1:m
if( d_ifft(k2,m2)<0)
d_ifft(k2,m2)=0;
end
end
end
d_ifft_paralleltoserial=d_ifft.';
CP_part=d_ifft_paralleltoserial(:,end -Ncp+1: end);
ACOOFDM_CP = [CP_part d_ifft_paralleltoserial];
theta = 70; %LED semi - angle
ml=-log10(2)/log10(cos(theta));
APD=0.01;
lx=5;ly=5;lz=3;
h =2.15;
[XT,YT]= meshgrid([-lx/4 lx/4],[-ly/4 ly/4]);
Nx=lx*5; Ny=ly*5;
x = linspace(-lx/2,lx/2,Nx);
y = linspace(-ly/2,ly/2,Ny);
[XR,YR] = meshgrid(x,y);
D1=sqrt((XR-XT(1,1)).^2+(YR-YT(1,1)).^2+h^2);
D2=sqrt((XR-XT(2,2)).^2+(YR-YT(2,2)).^2+h^2);
cosphi_A1=h./D1;
receiver_angle=acosd(cosphi_A1);
H_A1 = 3600*((ml+1)*APD.*cosphi_A1.^(ml+1)./(2*pi.*D1.^2)+(ml+1)*APD.*cosphi_A1.^(ml+1)./(2*pi.^2*D1.^2*D2.^2));
H_A2 = H_A1./norm(H_A1);
d_channell = filter(H_A2(1,1:2), 1, ACOOFDM_CP.').';
count=0;
snr_vector=0:1:30;
for snr=snr_vector
SNR=snr+10*log10(log2(M));
count=count+1;
ACOOFDM_with_chann=awgn(d_channell,SNR,'measured ') ;
ACOOFDM_removal_CP=ACOOFDM_with_chann(:,Ncp+1:N+Ncp);
ACOOFDM_serialtoparallel=ACOOFDM_removal_CP.';
ACOOFDM_parallel_fft=fft(ACOOFDM_serialtoparallel) ;
TransmittedPilots=DataMod_serialtoparallel(PLoc,:);
ReceivedPilots=ACOOFDM_parallel_fft(PLoc,:);
H_LS=ReceivedPilots./TransmittedPilots;
for r=1:m
H_MMSE(:,r)=MMSEesti(ReceivedPilots(:,r),TransmittedPilots(:,r),N,pilotFrequency,H_A2(1,1:2),SNR);
end
for q=1:m
HData_LS(:,q)=interpolate(H_LS(:,q).',PLoc,N,'spline ');
end
HData_LS_parallel1=HData_LS.';
HData_MMSE_parallel1=H_MMSE.';
ACOOFDM_SERIAL_LS=demodulate(Rx,(ACOOFDM_parallel_fft.') ./HData_LS_parallel1);
ACOOFDM_SERIAL_MMSE=demodulate(Rx,(ACOOFDM_parallel_fft.') ./(HData_MMSE_parallel1));
Data_no_pilots=Data(:,DLoc);
Recovered_Pilot_LS=ACOOFDM_SERIAL_LS(:,DLoc);
Recovered_Pilot_MMSE=ACOOFDM_SERIAL_MMSE(:,DLoc);
[~,recoveredLS(count)]=biterr(Data_no_pilots(:,2:255),Recovered_Pilot_LS(:,2:255));
[~,recoveredMMSE(count)]=biterr(Data_no_pilots(:,2:255),Recovered_Pilot_MMSE(:,2:255));
end
semilogy(snr_vector,recoveredLS,'rd-','LineWidth ' ,2);
holdon;
semilogy(snr_vector,recoveredMMSE,'gs-','LineWidth ',2);
axis([0 30 10^-4 1]);
grid on;

Answers (1)

Hanojhan Rajahrajasingh
Hanojhan Rajahrajasingh on 7 Feb 2023
Did you find a solution to this problem?

Community Treasure Hunt

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

Start Hunting!