OFDM MULTIPATH CODE LTE GENERAL
clc;
clear all;
close all;
% Initializing parameters
Nfft=input('Size of fft N = ');
Nused=input('Number of OFDM symbols to be used m = ');
M=input('Size of constellation M = ');
Type=input('Type of Mapping (1 for PSK) and (2 for QAM) = ');
Phase_Offset=input('phase offset = ');
Ncp=input('cyclic prefix samples Ncp = ');
bw = 15*10^6;%%bandwidth
T = 1/bw;%time period
% Transmitter
if Type == 1
Tx = modem.pskmod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray');
Rx = modem.pskdemod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray');
else
Tx = modem.qammod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray');
Rx = modem.qamdemod('M',M,'PhaseOffset',Phase_Offset,'SymbolOrder','gray');
end
%Indoor delay
in_delay = [0 50 110 170 290 310];
N_tap = ceil(max(in_delay)*(10^(-9))/T);
c_in = zeros(1,N_tap+1);
c_tap = ceil(in_delay./50)+1;
inPwr_dB = [0 -3 -10 -18 -26 -32];%% power in dB
inPwr = 10.^(inPwr_dB/10);%% converting to linear scale
c_r = abs(((inPwr/2).*randn(1,length(inPwr)))+((inPwr/2).*randn(1,length(inPwr)))*1i);
for k=1:length(c_tap)
c_in(c_tap(k))=c_r(k);
end
% c_in_s=sum(c_in);
% data generation
Tx_data=randi([0 M-1],Nused,Nfft/2);
% Mapping
mod_data=modulate(Tx,Tx_data);
% Serial to Parallel
s2p=mod_data.';
% insertion of pilots (upsmapling)
upsampled=upsample(s2p,2);
% Amplitude modulation (IDFT using fast version IFFT)
am=ifft(upsampled,Nfft);
% Parallel to serial
p2s=am.';
% Cyclic Prefixing
CP_part=p2s(:,Nfft-Ncp+1:Nfft); % this is the Cyclic Prefix part to be appended.
cp=[CP_part p2s];
% cp_v=reshape(cp,Nused,Nfft+Ncp);
%c_in_v=reshape(c_in,1,8);
conv_data=convn(cp ,c_in);
% Reciever
% Adding Noise using AWGN
SNRstart=3;
SNRincrement=2;
SNRend=11;
c=0;
r=zeros(size(SNRstart:SNRincrement:SNRend));
for snr=SNRstart:SNRincrement:SNRend
c=c+1;
noisy=awgn(conv_data,snr,'measured');
% Remove cyclic prefix part
cpr=noisy(:,Ncp+1:Nfft+Ncp); %remove the Cyclic prefix
% serial to parallel
parallel=cpr.';
% Amplitude demodulation (DFT using fast version FFT)
amdemod=fft(parallel,Nfft);
% Down-Sampling
downsampled=downsample(amdemod,2);
% Parallel to serial
rserial=downsampled.';
% demodulation
Umap=demodulate(Rx,rserial);
% Calculating the Symbol Error Rate
[n, r(c)]=symerr(Tx_data,Umap);
end
figure(1)
snr=SNRstart:SNRincrement:SNRend;
% Plotting SER vs SNR
semilogy(snr,r,'-ok');
grid;
title('OFDM Symbol Error Rate vs SNR');
ylabel('Symbol Error Rate');
xlabel('SNR [dB]');
Cite As
raghav khandelwal (2024). OFDM MULTIPATH CODE LTE GENERAL (https://www.mathworks.com/matlabcentral/fileexchange/50845-ofdm-multipath-code-lte-general), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | GENERAL CODE |