将下面的代码中的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;
时间: 2024-01-24 15:20:26 浏览: 70
QPSK调制和解调代码
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;
阅读全文