skyforce111111
Newbie level 1
Hello my friends, I'm working on PAPR reduction technique in OFDM using Precode-DHT , I wrote my code but it doesn't give me the correct results.. is there any one can help me to do it correctly.
Thanks... and I'm waiting for response.
My Matlab code is:
Thanks... and I'm waiting for response.
My Matlab code is:
Code:
%% A. Orginal OFDM Signal
clc
clear all
N=64; % Number of subcarriers
P=4; % Number of piolt tones for channel estimation
CP=N/8; % Guard interval size
Nd=52; % Number of active data subcarriers
M=16; % Modulation level
K=log2(M); % Number of bits for M-QAM constellation
Tsym=4*10^-6; % Symbol period
EbNo=0:5:20; % Normalized signal to noise ratio
SNR=EbNo+10*log10(K); % Signal to noise ratio
BER=zeros(1,numel(SNR)); % Zero bit error rate
mod=modem.qammod('M',M,'SymbolOrder','Gray'); % QAM modulation using gray code algorthim
demod=modem.qamdemod(mod); % M-QAM demodulation
LP=1:4:N; % Pilot tones location 4u second
LD=setxor(1:N,LP); % Location of data on active subcarriers
EP=2; % Energy of pilot symbol
G=2*pi*1i/N.*meshgrid(0:N-1,0:N-1).* repmat([0:N-1]',1,N); % Generate random matrix for initializing fft
F=exp(G); % Initializing fft
T=0.01; % Clipping level
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Transmitter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:N
data_send=randint(N,1,M); % Data will be sent over OFDM systm
data_mod=modulate(mod,data_send); % Modulation using Gray code techbiuqe
%or
%data_m1=qammod(data_send,M) % Modulation using conventional M-QAM
%data_mod(LP)=EP*data_mod(LP) % To change elements in a matrix
%data_ep=EP*data_mod(LP); % Pilot data with EP=2
data_ifft=ifft(data_mod,N); % IFFT for Pilot subcarriers
data_cp=[data_ifft(N-CP+1:N);data_ifft]; % Guard interval inserting with size 8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Adding Channel Effect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rayl_ch=rayleighchan(Tsym,20); % Rayleigh channel for a bandwidth 20Mhz
data_ch=filter(rayl_ch,data_cp); % Data with channel effect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Reciever
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
data_re_cp=data_ch(CP+1:N+CP); % Removing the guard interval
data_fft=fft(data_re_cp,N); % FFT for the recieved data
data_demod=demodulate(demod,data_fft); % Data demodulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Channel estimation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pilot_send=data_mod(LP); % Transmitted pilot
pilot_recieved=data_fft(LP); % Recieved pilot
t_f_v=((EP*length(LP))^-1*ctranspose(sqrt(EP))*diag(pilot_send)*ctranspose(F(1:16,LP)));
% Channel estimation transfer function vector
estimated_ch=t_f_v*pilot_recieved; % estimated channel coefficients
received_bits=pskdemod(data_fft./(fft(estimated_ch,N)),M); % Received bits
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Calculating PAPR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mean_sqrt_value=data_ifft'*data_ifft/length(data_ifft); % Mean sqare value
max_value=max(data_ifft.*conj(data_ifft)); % Peak value
PAPR(i)=max_value/ mean_sqrt_value; % PAPR ratio
end
PAPR_dB=10*log10(PAPR); % PAPR in dB
[n p]=hist(PAPR_dB,0:0.5:25);
semilogy(p*0.3,fliplr(cumsum(n)*3.3/N)*0.3,'ko-')
hold on
grid on
%% B. DHT Precoding
for m=1:N
data_send1=randint(N,N,M); % Data will be sent over OFDM systm
data_mod1=modulate(mod,data_send1); % Modulation using Gray code techbiuqe
for r=1:length(data_send1)
if data_mod1(r)<-T
data_mod1(r)=-T; % clipping level
end
end
data_ep1=EP*data_mod1(LP);
data_clipping=data_mod1.*data_send1;
DHT=data_clipping*(cos((2*pi*m)/N)+sin((2*pi*m)/N));
data_ready_send=DHT(1:N)';
data_ifft1=ifft(data_ready_send,N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Calculating PAPR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mean_sqrt_value1=max(max(data_ifft1'*data_ifft1/length(data_ifft1))); % Mean sqare value
max_value1=max(data_ifft1.*conj(data_ifft1)); % Peak value
PAPR1(m)=max_value1/ mean_sqrt_value1; % PAPR ratio
end
PAPR_dB1=10*log10(PAPR1); % PAPR in dB
[n1 p1]=hist(PAPR_dB1,0:0.5:25);
semilogy(p1*0.3,fliplr(cumsum(n1)*3.3/N)*0.3,'gs-')
hold on
Last edited by a moderator: