%SCFDMA降低PAPR方法 压缩扩展法指数算法(u律)
clear
clc
dataType = 'QPSK'; % Modulation format.
totalSubcarriers = 512; % Number of total subcarriers.
numSymbols = 16; % Data block size.
Q = totalSubcarriers/numSymbols; % Bandwidth spreading factor of IFDMA.
Q_tilda = 31; % Bandwidth spreading factor of DFDMA. Q_tilda < Q.
subcarrierMapping = 'IFDMA'; % Subcarrier mapping scheme.
pulseShaping = 1; % Whether to do pulse shaping or not.
filterType = 'rc'; % Type of pulse shaping filter.
rolloffFactor = 0.0999999999; %Rolloff factor for the raised-cosine filter.
%To prevent divide-by-zero, for example, use 0.099999999 instead of 0.1.
Fs = 5e6; % System bandwidth.
Ts = 1/Fs; % System sampling rate.
Nos = 4; % Oversampling factor.
if filterType == 'rc' % Raised-cosine filter.
psFilter = rcPulse(Ts, Nos, rolloffFactor);
elseif filterType == 'rr' % Root raised-cosine filter.
psFilter = rrcPulse(Ts, Nos, rolloffFactor);
end
ITERATE_NUM = 3; %iterate_num=3,压扩滤波的次数
MAX_SYMBOLS=1000; %nuber of loop;
QPSK_SET=[1,-1,1i,-1i];
u1=2;
PAPR_RCF = zeros(ITERATE_NUM,MAX_SYMBOLS); %4行,10000列
PAPR_Orignal = zeros(1,MAX_SYMBOLS);
PAPR_yakuo1 = zeros(1,MAX_SYMBOLS);
for nSymbol = 1:MAX_SYMBOLS,
% Generate random data.
if dataType == 'QPSK'
tmp = round(rand(numSymbols,2));
tmp = tmp*2 - 1;
data = (tmp(:,1) + j*tmp(:,2))/sqrt(2);
elseif dataType == '16QAM'
dataSet = [-3+3i -1+3i 1+3i 3+3i ...
-3+i -1+i 1+i 3+i ...
-3-i -1-i 1-i 3-i ...
-3-3i -1-3i 1-3i 3-3i];
dataSet = dataSet / sqrt(mean(abs(dataSet).^2));
tmp = ceil(rand(numSymbols,1)*16);
for k = 1:numSymbols,
if tmp(k) == 0
tmp(k) = 1;
end
data(k) = dataSet(tmp(k));
end
data = data.';
end
% Convert data to frequency domain.
X = fft(data);
% Initialize the subcarriers.
Y = zeros(totalSubcarriers,1);
% Subcarrier mapping.
if subcarrierMapping == 'IFDMA'
Y(1:Q:totalSubcarriers) = X;
elseif subcarrierMapping == 'LFDMA'
Y(1:numSymbols) = X;
elseif subcarrierMapping == 'DFDMA'
Y(1:Q_tilda:Q_tilda*numSymbols) = X;
end
% Convert data back to time domain.
y = ifft(Y);
% y_oversampled=zeros(1,K);
% Perform pulse shaping.
if pulseShaping == 1
% Up-sample the symbols.
y_oversampled(1:Nos:Nos*totalSubcarriers) = y;
% Perform filtering.
y_result = filter(psFilter, 1, y_oversampled);
else
y_result = y;
end
% y_result=[y(1:totalSubcarriers/2) zeros(3*totalSubcarriers,1) y(totalSubcarriers/2+1:totalSubcarriers)]; %4倍过采样
% Calculate the PAPR.
PAPR_Orignal(nSymbol) = 10*log10(max(abs(y_result).^2) / mean(abs(y_result).^2));
%压缩扩张
basignal1=y_result;
m=mean(abs(y_result));
basignal1=(m/log(1+u1))*log(1+u1*abs(y_result)/m).*(y_result./abs(y_result));
signal_power1=abs(basignal1.^2);
peak_power1=max(signal_power1,[],2);
mean_power1=mean(signal_power1,2);
PAPR_yasuo1(nSymbol) =10*log10(peak_power1/mean_power1);%压缩扩张信号的papr
% %压扩滤波
% for nIter=1:ITERATE_NUM
% m=mean(abs(y_result));
% y_result=(m/log(1+u1))*log(1+u1*abs(y_result)/m).*(y_result./abs(y_result));
%
% % Filtering
% Z = fft(y_result,[],2); %按行求FFT,1*256个
% Z(subc/2+(1:3*subc)) = zeros(1,3*subc); %通过带外置零进行人工滤波%%括号里的式子相当于(subc/2+1):(4*subc-subc/2),那就是把XX中的第(subc/2+1)到(4*subc-subc/2)个给赋值为0,其长度恰好为3*subc,和零矩阵的长度匹配
% y_result = ifft(Z,[],2); % 按行求IFFT,1行,256列
%
% signal_power1=abs(y_result.^2);
% peak_power1=max(signal_power1,[],2);
% mean_power1=mean(signal_power1,2);
% papr_RCF(nIter,nSymbol) =10*log10(peak_power1/mean_power1);
%
% end
end
[cdf1, PAPR1] = ecdf(PAPR_Orignal);
[cdf2, PAPR2] = ecdf(PAPR_yasuo1);
semilogy(PAPR1,1-cdf1,'-b',PAPR2,1-cdf2,'-r')
legend('Orignal','压缩扩展法u律')
title('SC-FDMA系统压缩扩展法u律')
xlabel('PAPR0 [dB]');
ylabel('CCDF (Pr[PAPR>PAPR0])');
grid on
% Plot CCDF.
% [N,X] = hist(PAPR_Orignal, 100);
% semilogy(X,1-cumsum(N)/max(cumsum(N)),'b')
% hold on;
% [N,X] = hist(PAPR_PTS, 100);
% semilogy(X,1-cumsum(N)/max(cumsum(N)),'r')
% Save data.
save paprSCFDMAyakuoulv