可以仿真的锁相环的matlab代码

上传人:桔**** 文档编号:506453243 上传时间:2022-07-20 格式:DOCX 页数:3 大小:9.20KB
返回 下载 相关 举报
可以仿真的锁相环的matlab代码_第1页
第1页 / 共3页
可以仿真的锁相环的matlab代码_第2页
第2页 / 共3页
可以仿真的锁相环的matlab代码_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《可以仿真的锁相环的matlab代码》由会员分享,可在线阅读,更多相关《可以仿真的锁相环的matlab代码(3页珍藏版)》请在金锄头文库上搜索。

1、%频偏:-60Hz%相偏:在02*pi内随机分布% 程序及结果如下:clear all;close all;%定义锁相环的工作模式:单载波为“1”、BPSK调制为“2”、QPSK调制为“3”PLL_Mode = 3;%仿真数据长度 Simulation_Length=1000;%基带信号if PLL_Mode = 1I_Data=ones(Simulation_Length,1);Q_Data=I_Data;else if PLL_Mode = 2I_Data=randint(Simulation_Length,1)*2-1; Q_Data=zeros(Simulation_Length,1)

2、;else I_Data=randint(Simulation_Length,1)*2-1;Q_Data=randint(Simulation_Length,1)*2-1;endend Signal_Source=I_Data + j*Q_Data;% 载波信号Freq_Sample=2400;%采样率,HzDelta_Freq=-60; %频偏, Hz Time_Sample=1/Freq_Sample;Delta_Phase=rand(1)*2*pi; %随机初相,RadCarrier=exp(j*(Delta_Freq/Freq_Sample*(1:Simulation_Length)+

3、Delta_Phase); % 调制处理Signal_Channel=Signal_Source.*Carrier; %以下为锁相环处理过程% 参数清零 Signal_PLL=zeros(Simulation_Length,1);NCO_Phase = zeros(Simulation_Length,1); Discriminator_Out=zeros(Simulation_Length,1);Freq_Control=zeros(Simulation_Length,1);PLL_Phase_Part=zeros(Simulation_Length,1);PLL_Freq_Part=zero

4、s(Simulation_Length,1);% 环路处理C1=0.22013;C2=0.0024722;for i=2:Simulation_LengthSignal_PLL(i)=Signal_Channel(i)*exp(-j*mod(NCO_Phase(i-1),2*pi); I_PLL(i)=real(Signal_PLL(i);Q_PLL(i)=imag(Signal_PLL(i);if PLL_Mode = 1 Discriminator_Out(i)=atan2(Q_PLL(i),I_PLL(i);else if PLL_Mode = 2 Discriminator_Out(i

5、)=sign(I_PLL(i)*Q_PLL(i)/abs(Signal_PLL(i);elseDiscriminator_Out(i)=(sign(I_PLL(i)*Q_PLL(i)-sign(Q_PLL(i)*I_PLL(i). /(sqrt(2)*abs(Signal_PLL(i);endendPLL_Phase_Part(i)=Discriminator_Out(i)*C1; Freq_Control(i)=PLL_Phase_Part(i)+PLL_Freq_Part(i-1);PLL_Freq_Part(i)=Discriminator_Out(i)*C2+PLL_Freq_Part

6、(i-1);NCO_Phase(i)=NCO_Phase(i-1)+Freq_Control(i);end%画图显示结果figuresubplot(2,2,1) plot(-PLL_Freq_Part(2:Simulation_Length)*Freq_Sample);grid on;title(锁相环频率响应曲线);axis(1 Simulation_Length -100 100);subplot(2,2,2) plot(PLL_Phase_Part(2:Simulation_Length)*180/pi);title(锁相环相位响应曲线);axis(1 Simulation_Length

7、 -2 2);gridon;%设定显示范围Show_D=300; %起始位置Show_U=900; %终止位置Show_Length=Show_U-Show_D;subplot(2,2,3)plot(Signal_Channel(Show_D:Show_U),*);title( 进入锁相环的数据星座图);axis(-2 2 -2 2);gridon;holdon;subplot(2,2,3)plot(Signal_PLL(Show_D:Show_U),r*);gridon; subplot(2,2,4)plot(Signal_PLL(Show_D:Show_U),r*);title( 锁相环锁

8、定及稳定后的数据星座图);axis(-2 2 -2 2); grid on;figure%设定显示范围Show_D=300; %起始位置Show_U=350; %终止位置 Show_Length=Show_U-Show_D; subplot(2,2,1) plot(I_Data(Show_D:Show_U); grid on;title( I路信息数据);axis(1 Show_Length -2 2); subplot(2,2,2) plot(Q_Data(Show_D:Show_U); gridon;title( Q路信息数据);axis(1 Show_Length -2 2); subplot(2,2,3) plot(I_PLL(Show_D:Show_U); gridon;title(锁相环输出I路信息数据);axis(1 Show_Length -2 2); subplot(2,2,4) plot(Q_PLL(Show_D:Show_U); gridon;title(锁相环输出Q路信息数据);axis(1 Show_Length -2 2);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号