clear all
clc;
ccdf1=zeros(1,131);
ccdf2=zeros(1,131);
ccdf3=zeros(1,131);
aa=zeros(1,512);
b=zeros(1,512);
c=zeros(1,512);
for n=1:100
a=rand(1,256)>0.5;%生成一个1*256的矩阵
%对矩阵A进行QPSK映射并串并变换
C=(a*2-1)/sqrt(2);
sreal=C(1:2:256);
simage=C(2:2:256);
D=sreal+j.*simage;
% oversample 4
z1=[D(1:128/2),zeros(1,3*128),D(128/2+1:128)];
z2=ifft(z1)*128;
z2=real(z2);
x0=abs(z2).^2;
m0=mean(x0);
u=2;
for i=1:512
if z2(1,i)>0
aa(1,i)=m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
else
aa(1,i)=-1*m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
end
end
x1=abs(aa).^2;
v1=max(x1);
m1=mean(x1);
papr1(n)=10*log10(v1/m1);
u=3;
for i=1:512
if z2(1,i)>0
b(1,i)=m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
else
b(1,i)=-1*m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
end
end
x2=abs(b).^2;
v2=max(x2);
m2=mean(x2);
papr2(n)=10*log10(v2/m2);
u=4;
for i=1:512
if z2(1,i)>0
c(1,i)=m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
else
c(1,i)=-1*m0*log(1+u*abs(z2(1,i))/m0)/log(1+u);
end
end
x3=abs(c).^2;
v3=max(x3);
m3=mean(x3);
papr3(n)=10*log10(v3/m3);
end
NN=0:.1:13;
for n=1:100;
for l=1:131;
if papr1(n)>NN(l);
ccdf1(l)=ccdf1(l)+1;
end
if papr2(n)>NN(l);
ccdf2(l)=ccdf2(l)+1;
end
if papr3(n)>NN(l);
ccdf3(l)=ccdf3(l)+1;
end
end
end
ccdf1=ccdf1/100;
ccdf2=ccdf2/100;
ccdf3=ccdf3/100;
figure(1)
semilogy(NN,ccdf1,'r',NN,ccdf2,'b',NN,ccdf3,'k')
title('不同u值时的CCDF曲线')
xlabel('papr(dB)'),ylabel('ccdf')
legend('u=2','u=3','u=4');
grid on