⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 上交1.m

📁 本程序用于仿真QPSK的解调
💻 M
字号:
clear all;
N=1000;  %码元个数
fs=250;   %采样率;
fd=1;     %输出符号率(码速率);
fc=100;   %载波频率;
%调制部分的程序
    A = (rand(1,N)>0.5)*2 - 1; %产生随机的+、-1序列
    B = (rand(1,N)>0.5)*2 - 1; %产生随机的+、-1序列

A_jidai=rcosflt(A,fd,fs,'fir/sqrt',0.35,3);   %基带成形
B_jidai=rcosflt(B,fd,fs,'fir/sqrt',0.35,3);   %基带成形

[s1,t1]=size(A_jidai);
[s2,t2]=size(B_jidai);
i=1:s1;
    Q=B_jidai'.*sin(2*pi*fc*i/fs);   %Q路调制
    I=A_jidai'.*cos(2*pi*fc*i/fs);   %I路调制
    T=I+Q;

T_with_noise = awgn(T,7,'measured');  %加入Gauss白噪声
%plot(T_with_noise);

i=1:s1;
     I_re1=T_with_noise.*cos(2*pi*fc*i/fs);   %接收端下变频
     Q_re1=T_with_noise.*sin(2*pi*fc*i/fs);   %接收端下变频
     
     h1=fir1(48,0.25);          %允许相对码速率由1/4的频偏
     I_re=filter(h1,1,I_re1);   %滤除倍频分量
     Q_re=filter(h1,1,Q_re1);   %滤除倍频分量
 
 
 n=3*fs/fd:(fs/fd):s1-4*fs/fd;  %按照码速率采样
 A_with_noise=I_re(n);
 B_with_noise=Q_re(n);
 
 k1=0.13;   %环路滤波器参数值设定
 k2=0.17;   %环路滤波器参数值设定


 f_err = 0;              %相对于码速率的初始频偏 初始值
phase_err = 0;           %初始相偏 初始值


f_err_estimated(1) = 0;                 %相对于码速率的初始频偏 初始估计值
phase_err_estimated(1) = 0;             %初始相偏 初始估计值
delta_f(1)=0;

for m = 1:length(n)
    if(m == 1)
        delta_phase(m) = phase_err_estimated(m);
    else
        delta_phase(m) = delta_phase(m - 1) + f_err_estimated(m) + phase_err_estimated(m)-phase_err_estimated(m-1);
    end    
    A_received(m) = A_with_noise(m)*cos(delta_phase(m)) - B_with_noise(m)*sin(delta_phase(m));  %旋转变换
    B_received(m) = A_with_noise(m)*sin(delta_phase(m)) + B_with_noise(m)*cos(delta_phase(m));  %旋转变换     
    phase_err(m) = -(angle(A_received(m) + j*B_received(m)) - angle(sign(A_received(m)) + j*sign(B_received(m)))); 
    
    %angle(sign(A_received(m)) + j*sign(B_received(m))) 星座点的相位
    
    
    if(m==1)
            f_err_estimated(m+1)=f_err_estimated(m) ;
            phase_err_estimated(m+1)=phase_err(m);
        else
           delta_f(m)=delta_f(m-1) + f_err_estimated(m);
            f_err_estimated(m+1) = k1*(phase_err(m)-phase_err(m-1)-f_err_estimated(m))+f_err_estimated(m);
           phase_err_estimated(m+1) =  k2*(phase_err(m)-delta_f(m)-phase_err_estimated(m))+phase_err_estimated(m);
       end
   end
    
%误差信号驱动环路滤波器进行预测

subplot(3,1,1)
plot(f_err - f_err_estimated)
title('相对码速率的残余频差')
grid minor
subplot(3,1,2)
plot(delta_phase - round(delta_phase/(pi/2))*pi/2)
title('残余相差(与pi/2的整数倍的差值)')
grid minor
subplot(3,1,3)
stem(phase_err/(pi/4))
title('判决的调制相位偏离星座点的距离(归一化)')
grid minor

k=sum(xor([A>0,B>0],[A_with_noise>0,B_with_noise>0]))/length([A,B])%载波完全同步情况下的误码率
d=sum(xor(A>0,A_received>0))/length(A)%在这个算法的条件下的误码率

%var(delta_phase - round(delta_phase/(pi/2))*pi/2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -