function PAPR_QPSK_Clipping2 Num_Loop=10000;%总共模拟10000个点,数字越大越精确 Num_Subcarrier=64;%子载波个数 Mapper=[3+3i 1+3i -1+3i -3+3i 3+1i 1+1i -1+1i -3+1i 3-1i 1-1i -1-1i -3-1i 3-3i 1-3i -1-3i -3-3i]/sqrt(4);%QPSK J=5;0%Oversampling factor过采样因子 CR=1;%Clipping Ratio裁剪比 PAPR_Original=zeros( 1,Num_Loop); PAPR_Clipping=zeros(1,Num_Loop); for n=1:Num_Loop InputSymbolIndex=randi([1 16],1,Num_Subcarrier); OFDM_Freq=Mapper(InputSymbolIndex); OFDM_Time=sqrt(J*Num_Subcarrier)*ifft([OFDM_Freq(1:Num_Subcarrier/2) zeros(1,(J-1)*Num_Subcarrier) OFDM_Freq(Num_Subcarrier/2+1:Num_Subcarrier)]); PAPR_Original(n)=10*log10(max(abs(OFDM_Time))^2./mean(abs(OFDM_Time).^2)); for p=1:J*Num_Subcarrier if abs(OFDM_Time(p))>CR OFDM_Time(p)=CR*cos(angle(OFDM_Time(p)))+1i*CR*sin(angle(OFDM_Time(p))); end end PAPR_Clipping(n)=10*log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).^2)); end Pr_Ori=[]; Pr_Clip=[]; PAPRO_Start=2; PAPRO_End=12; step=0.2; count=1; for m=PAPRO_Start:step:PAPRO_End temp_Ori=sum(PAPR_Original(:)>m)/Num_Loop; temp_Clip=sum(PAPR_Clipping(:)>m)/Num_Loop; Pr_Ori(count)=temp_Ori; Pr_Clip(count)=temp_Clip; count=count+1; end semilogy(PAPRO_Start:step:PAPRO_End,Pr_Ori, '-b*',PAPRO_Start:step:PAPRO_End,Pr_Clip, '-r*'); axis([PAPRO_Start PAPRO_End 10^-4 1]); grid on; hold on:
时间: 2024-01-30 07:02:36 浏览: 101
这是一个MATLAB代码,用于模拟QPSK信号的峰均功率比(PAPR)及其裁剪对系统性能的影响。具体来说,代码首先生成64个QPSK符号,并将其映射到64个子载波上。然后,通过进行IFFT将频域信号转换为时域信号。接下来,对于每个时域样本,如果其幅度超过预定义的裁剪比,则将其幅度限制在裁剪比范围内。最终,代码计算原始信号和裁剪后信号的PAPR,并绘制PAPR分布曲线。
在绘制PAPR分布曲线时,代码使用了semilogy函数来绘制对数坐标轴上的数据。其中,蓝色星号表示原始信号的PAPR分布,红色星号表示裁剪后信号的PAPR分布。此外,代码还设置了坐标轴范围和网格以改善可视化效果。
相关问题
function PAPR_QPSK_Clipping Num_Loop=10000;%总共模拟10000个点,数字越大越精确 Num_Subcarrier=64;%子载波个数 Mapper=[1+1i -1+1i 1-1i -1-1i]/sqrt(2);%QPSK J=5;0%Oversampling factor过采样因子 CR=1;%Clipping Ratio裁剪比 PAPR_Original=zeros( 1,Num_Loop); PAPR_Clipping=zeros(1,Num_Loop); for n=1:Num_Loop InputSymbolIndex=randi([1 4],1,Num_Subcarrier); OFDM_Freq=Mapper(InputSymbolIndex); OFDM_Time=sqrt(J*Num_Subcarrier)*ifft([OFDM_Freq(1:Num_Subcarrier/2) zeros(1,(J-1)*Num_Subcarrier) OFDM_Freq(Num_Subcarrier/2+1:Num_Subcarrier)]); PAPR_Original(n)=10*log10(max(abs(OFDM_Time))^2./mean(abs(OFDM_Time).^2)); for p=1:J*Num_Subcarrier if abs(OFDM_Time(p))>CR OFDM_Time(p)=CR*cos(angle(OFDM_Time(p)))+1i*CR*sin(angle(OFDM_Time(p))); end end PAPR_Clipping(n)=10*log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).^2)); end Pr_Ori=[]; Pr_Clip=[]; PAPRO_Start=2; PAPRO_End=12; step=0.2; count=1; for m=PAPRO_Start:step:PAPRO_End temp_Ori=sum(PAPR_Original(:)>m)/Num_Loop; temp_Clip=sum(PAPR_Clipping(:)>m)/Num_Loop; Pr_Ori(count)=temp_Ori; Pr_Clip(count)=temp_Clip; count=count+1; end semilogy(PAPRO_Start:step:PAPRO_End,Pr_Ori, '-y*',PAPRO_Start:step:PAPRO_End,Pr_Clip, '-g*'); axis([PAPRO_Start PAPRO_End 10^-4 1]); grid on; hold on:
这段代码是一个用MATLAB实现的PAPR(峰均比)模拟程序,用于比较原始OFDM信号和进行裁剪处理后的信号的PAPR性能。其中QPSK调制信号通过FFT变换转换成OFDM信号,然后进行裁剪处理,最终统计PAPR性能。在程序的最后,使用semilogy函数将原始信号和裁剪后信号的PAPR性能进行比较并绘制成图像。
将下面的代码中的QPSK调制改为8QPSK调制 : function PAPR_QPSK_Clipping Num_Loop=30000; Num_Subcarrier=64; Mapper=[ 1+1i -1+1i 1-1i -1-1i]/sqrt(2);%QPSK %Mapper=[-3+3j,-1+3j,1+3j,3+3j,... % -3+1j,-1+1j,1+1j,3+1j,... % -3-1j,-1-1j,1-1j,3-1j,... % -3-3j,-1-3j,1-3j,3-3j];%16QAM % J=5;%Oversampling factor CR=4;%Clipping Ratio PAPR_Original=zeros(1,Num_Loop); PAPR_Clipping=zeros(1,Num_Loop); for n=1:Num_Loop InputSymbolIndex=randi([1 4],1,Num_Subcarrier); OFDM_Freq=Mapper(InputSymbolIndex); OFDM_Time=sqrt(JNum_Subcarrier)ifft([OFDM_Freq(1:Num_Subcarrier/2) zeros(1,(J-1)Num_Subcarrier) OFDM_Freq(Num_Subcarrier/2+1:Num_Subcarrier)]); PAPR_Original(n)=10log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).2)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Clipping Method for p=1:JNum_Subcarrier if abs(OFDM_Time(p))>CR OFDM_Time(p)= CRcos(angle(OFDM_Time(p)))+1iCRsin(angle(OFDM_Time(p))); end end PAPR_Clipping(n)=10log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).^2)); end Pr_Ori=[]; Pr_Clip=[]; PAPRO_Start=2; PAPRO_End=12; step=0.2; count=1; for m=PAPRO_Start:step:PAPRO_End temp_Ori=sum(PAPR_Original(:)>m)/Num_Loop; temp_Clip=sum(PAPR_Clipping(:)>m)/Num_Loop; Pr_Ori(count)=temp_Ori; Pr_Clip(count)=temp_Clip; count=count+1; end semilogy(PAPRO_Start:step:PAPRO_End,Pr_Ori,' -b*',PAPRO_Start:step:PAPRO_End,Pr_Clip,'-r*'); axis([PAPRO_Start PAPRO_End 10^-4 1]); grid on; hold on;
function PAPR_8QPSK_Clipping
Num_Loop=30000;
Num_Subcarrier=64;
Mapper=[-1/sqrt(2)-1/sqrt(2)*1i -1/sqrt(2)+1/sqrt(2)*1i 1/sqrt(2)-1/sqrt(2)*1i 1/sqrt(2)+1/sqrt(2)*1i -1/sqrt(2)-1/sqrt(2)*1i 1/sqrt(2)-1/sqrt(2)*1i -1/sqrt(2)+1/sqrt(2)*1i 1/sqrt(2)+1/sqrt(2)*1i]/sqrt(2); % 8QPSK
J=5;%Oversampling factor
CR=4;%Clipping Ratio
PAPR_Original=zeros(1,Num_Loop);
PAPR_Clipping=zeros(1,Num_Loop);
for n=1:Num_Loop
InputSymbolIndex=randi([1 8],1,Num_Subcarrier);
OFDM_Freq=Mapper(InputSymbolIndex);
OFDM_Time=sqrt(J*Num_Subcarrier)*ifft([OFDM_Freq(1:Num_Subcarrier/2) zeros(1,(J-1)*Num_Subcarrier) OFDM_Freq(Num_Subcarrier/2+1:Num_Subcarrier)]);
PAPR_Original(n)=10*log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).^2));
% Clipping Method
for p=1:J*Num_Subcarrier
if abs(OFDM_Time(p))>CR
angle_OFDM_Time = angle(OFDM_Time(p));
if angle_OFDM_Time > -pi/8 && angle_OFDM_Time <= pi/8
OFDM_Time(p) = CR/sqrt(2) + 1i*CR/sqrt(2);
elseif angle_OFDM_Time > pi/8 && angle_OFDM_Time <= 3*pi/8
OFDM_Time(p) = 1/sqrt(2) + 1i*CR;
elseif angle_OFDM_Time > 3*pi/8 && angle_OFDM_Time <= 5*pi/8
OFDM_Time(p) = -CR/sqrt(2) + 1i*CR/sqrt(2);
elseif angle_OFDM_Time > 5*pi/8 && angle_OFDM_Time <= 7*pi/8
OFDM_Time(p) = -1/sqrt(2) + 1i*CR;
elseif angle_OFDM_Time > 7*pi/8 || angle_OFDM_Time <= -7*pi/8
OFDM_Time(p) = -CR/sqrt(2) - 1i*CR/sqrt(2);
elseif angle_OFDM_Time > -7*pi/8 && angle_OFDM_Time <= -5*pi/8
OFDM_Time(p) = -1/sqrt(2) - 1i*CR;
elseif angle_OFDM_Time > -5*pi/8 && angle_OFDM_Time <= -3*pi/8
OFDM_Time(p) = CR/sqrt(2) - 1i*CR/sqrt(2);
elseif angle_OFDM_Time > -3*pi/8 && angle_OFDM_Time <= -pi/8
OFDM_Time(p) = 1/sqrt(2) - 1i*CR;
end
end
end
PAPR_Clipping(n)=10*log10(max(abs(OFDM_Time)).^2./mean(abs(OFDM_Time).^2));
end
Pr_Ori=[];
Pr_Clip=[];
PAPRO_Start=2;
PAPRO_End=12;
step=0.2;
count=1;
for m=PAPRO_Start:step:PAPRO_End
temp_Ori=sum(PAPR_Original(:)>m)/Num_Loop;
temp_Clip=sum(PAPR_Clipping(:)>m)/Num_Loop;
Pr_Ori(count)=temp_Ori;
Pr_Clip(count)=temp_Clip;
count=count+1;
end
semilogy(PAPRO_Start:step:PAPRO_End,Pr_Ori,' -b*',PAPRO_Start:step:PAPRO_End,Pr_Clip,'-r*');
axis([PAPRO_Start PAPRO_End 10^-4 1]);
grid on;
hold on;
阅读全文