# MATLAB代做-OFDM-PAPR-PTS算法的仿真

### 时间：2019-1-16 17:13:41 点击：

核心提示：MATLAB代做-OFDM-PAPR-PTS算法的仿真...
clear
%==========================OFDM和加上PTS的CCDF V＝4 随机生成，并且bv的相位只有两种情况【1，－1】===
% common settings
%=================
wordsize=2;
NumCarr=256;              % Number of transmission carriers
Lcp=32;            % Guard Interval(length of cyclic extension)=12.5% of NumCarr
FrameGuard=NumCarr+Lcp;  % Guard Time between successive frames (one symbol period)
delay=2;
Numsymb=100;
seed=1234;
rand('seed',seed);                     % Set to new seed
w=round(rand(1,Numsymb));                   % generate Wk

%生成数据和导频图案
Pattern=ones(NumCarr,Numsymb);  % the position of data is set as 1.
Pattern(129,:)=0;                 % DC=0
Pattern([1:28,230:256],:)=0;      % guard band=0
Pattern([45:24:213],:)=4;% the position of pilot is set as 4.
%Pattern(:,[1,2])=0;
Data_Pattern=find(Pattern==1);   %the pattern of data

%生成数据矩阵
Data=zeros(size(Pattern));
for n=1:Numsymb
Data([45,93,189,213],n)=1-2*w(n);      % [-84,-36,60,84]=1-2W
Data([69,117,141,165],n)=2*w(n)-1;     % [-60,-12,12,36]=1-2W'
end

Data_Pattern=find(Pattern==1);   %the pattern of data
clear pattern
Datatx=floor(rand(1,length(Data_Pattern))*(2^wordsize));  % Generate the data
Tx=dec2bin(Datatx,wordsize)-48;
% Mapping to the signal constellation follow
mapping=get80216map(2^wordsize);% 调用.p文件。
for k=1:length(Datatx)
ModSignal(k)=mapping(1+Datatx(k));
end;

Data(Data_Pattern)=ModSignal;
clear ModSignal
%=================================== No PTS，计算PAPR=============================
NoPts=ifft(Data);
SNoptsPAR=zeros(1,Numsymb);
NoptsPar=zeros(1,NumCarr);
for n=1:Numsymb
for m=1:NumCarr
NoptsPar(m)=norm(NoPts(m,n))^2;
end;
NoPtsMean=mean(NoptsPar);
NoPtsMax=max(NoptsPar);
SNoptsPAR(n)=NoPtsMax/NoPtsMean;
end;

SNoptsPAR=10*log10(SNoptsPAR);                  % 计算对数PAPR

Xvalve=0:0.25:12;
countnopts=zeros(1,49);
for k=1:Numsymb
for n=1:49
if SNoptsPAR(k)>(n/4)
countnopts(n)=countnopts(n)+1;
end;
end;
end;
countnopts=countnopts./Numsymb;
%figure
semilogy(Xvalve,countnopts,'-b.')               % ====== without PTS ========
hold on

%===================================加PTS,V=8=================**********
%==========================================================================
V=8;                                 %每个符号分8路
BaseDataV8=zeros(NumCarr,V,Numsymb); %Numsymb个符号每个符号256个子载波，每个符号分8路
for n=1:Numsymb
for m=1:V
BaseDataV8(((m-1)*NumCarr/V+1):(m*NumCarr/V),m,n)=Data(((m-1)*NumCarr/V+1):(m*NumCarr/V),n);
end;
end;
BaseDataIfftV8=BaseDataV8;           % PTS的 V 路信号经过IFFT，大小为：(NumCarr,V,Numsymb)

B=[1,-1] ;                           % bv取两种相位
Bkinds=2^V;
BData=[-1 -1 -1 -1 -1 -1 -1;-1 -1 -1 -1 -1 -1 1;-1 -1 -1 -1 -1 1 -1;-1 -1 -1 -1 -1 1 1;-1 -1 -1 -1 1 -1 -1;-1 -1 -1 -1 1 -1 1;-1 -1 -1 -1 1 1 -1;-1 -1 -1 -1 1 1 1;
-1 -1 -1 1 -1 -1 -1;-1 -1 -1 1 -1 -1 1;-1 -1 -1 1 -1 1 -1;-1 -1 -1 1 -1 1 1;-1 -1 -1 1 1 -1 -1;-1 -1 -1 1 1 -1 1;-1 -1 -1 1 1 1 -1;-1 -1 -1 1 1 1 1;
-1 -1 1 -1 -1 -1 -1;-1 -1 1 -1 -1 -1 1;-1 -1 1 -1 -1 1 -1;-1 -1 1 -1 -1 1 1;-1 -1 1 -1 1 -1 -1;-1 -1 1 -1 1 -1 1;-1 -1 1 -1 1 1 -1;-1 -1 1 -1 1 1 1;
-1 -1 1 1 -1 -1 -1;-1 -1 1 1 -1 -1 1;-1 -1 1 1 -1 1 -1;-1 -1 1 1 -1 1 1;-1 -1 1 1 1 -1 -1;-1 -1 1 1 1 -1 1;-1 -1 1 1 1 1 -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1 -1 -1;1 -1 1 1 -1 -1 1;1 -1 1 1 -1 1 -1;1 -1 1 1 -1 1 1;1 -1 1 1 1 -1 -1;1 -1 1 1 1 -1 1;1 -1 1 1 1 1 -1;1 -1 1 1 1 1 1;
1 1 -1 -1 -1 -1 -1;1 1 -1 -1 -1 -1 1;1 1 -1 -1 -1 1 -1;1 1 -1 -1 -1 1 1;1 1 -1 -1 1 -1 -1;1 1 -1 -1 1 -1 1;1 1 -1 -1 1 1 -1;1 1 -1 -1 1 1 1;
1 1 -1 1 -1 -1 -1;1 1 -1 1 -1 -1 1;1 1 -1 1 -1 1 -1;1 1 -1 1 -1 1 1;1 1 -1 1 1 -1 -1;1 1 -1 1 1 -1 1;1 1 -1 1 1 1 -1;1 1 -1 1 1 1 1;
1 1 1 -1 -1 -1 -1;1 1 1 -1 -1 -1 1;1 1 1 -1 -1 1 -1;1 1 1 -1 -1 1 1;1 1 1 -1 1 -1 -1;1 1 1 -1 1 -1 1;1 1 1 -1 1 1 -1;1 1 1 -1 1 1 1;
1 1 1 1 -1 -1 -1;1 1 1 1 -1 -1 1;1 1 1 1 -1 1 -1;1 1 1 1 -1 1 1;1 1 1 1 1 -1 -1;1 1 1 1 1 -1 1;1 1 1 1 1 1 -1;1 1 1 1 1 1 1;]';

BBData=zeros(8,256);
BBData(1,1:128)=-1;
BBData(1,129:256)=1;
BBData(2:8,1:128)=BData;
BBData(2:8,129:256)=BData;
BData=BBData;

BaseDMuxBV8=zeros(NumCarr,Bkinds);
SigBDataNum=zeros(1,Numsymb);       % 每个符号最终选定的BData的组号
ParNorm=zeros(2,Bkinds);            % 1个符号的256种PAR的值（2，：）及其对应的BData的组号（1，：）
Mean=zeros(1,Bkinds);               % 一个符号对应的各组bv加权之后的ifft变换的PAR均值
Max=zeros(1,Bkinds);                % 一个符号对应的各组bv加权之后的ifft变换的PAR最大值
PTSSignal=zeros(NumCarr,Numsymb);   % 最终选择的PTS符号
SigParNorm=zeros(1,Numsymb);        % 最终选择的PTS符号的PAR值
for n=1:Numsymb
for k=1:Bkinds
for m=1:NumCarr
BaseDMuxBV8(m,k)=BaseDataIfftV8(m,1,n)*BData(1,k)+BaseDataIfftV8(m,2,n)*BData(2,k)+BaseDataIfftV8(m,3,n)*BData(3,k)+BaseDataIfftV8(m,4,n)*BData(4,k)+BaseDataIfftV8(m,5,n)*BData(5,k)+BaseDataIfftV8(m,6,n)*BData(6,k)+BaseDataIfftV8(m,7,n)*BData(7,k)+BaseDataIfftV8(m,8,n)*BData(8,k);
end;
BaseDMuxBV8(:,k)=ifft(BaseDMuxBV8(:,k));        %在IFFT之前加权，要在IFFT之后计算papr值进行bv赛选(bv未经线性变换)
for m=1:NumCarr
BaseDMuxBV8(m,k)=(norm(BaseDMuxBV8(m,k)))^2;
end;
Mean(k)=mean(BaseDMuxBV8(:,k));
Max(k)=max(BaseDMuxBV8(:,k));
end;
ParNorm(2,:)=Max./Mean;
MMin=min(ParNorm(2,:));                   % 一个符号的Bkinds种加权种选择PAPR最小的一组

SigParNorm(n)=MMin;
end;

SigParNorm=10*log10(SigParNorm);               % 计算对数PAPR

Xvalve=0:0.25:12;
count3=zeros(1,49);
for k=1:Numsymb
for n=1:49
if SigParNorm(k)>(n/4)
count3(n)=count3(n)+1;
end;
end;
end;
count3=count3./Numsymb;
%figure
semilogy(Xvalve,count3,'-r+')

xlim([4,12]),ylim([10^(-3),1])
grid on
xlabel('PAPR0(dB)'),ylabel('Pr(PAPR>PAPR0)')
legend('Original OFDM','PTS with V=8')

QQ ：1224848052

Tags:PTS

• 百度搜索