📄 ygqpsk.txt
字号:
clear
clc
fs=400;
f1=400;
Ts=1/fs;
source=randint(1,20,4);%产生随机的四进制的随机码
N=length(source); %码元向量长度
n=1;%设定初始值
K=1:N;
while n<=N %开始对码元逐个调制
t=(n-1)*Ts:Ts/19:n*Ts;%限定在Ts内时间的取样
CI1=cos(2*pi*f1*t+2*pi*f1*(n-1)*Ts+pi/4);%实现fc振荡(在一个周期内)
CI2=cos(2*pi*f1*t+2*pi*f1*(n-1)*Ts+pi.*3/4);%实现fc振荡(在一个周期内)
CI3=cos(2*pi*f1*t+2*pi*f1*(n-1)*Ts+pi.*5/4);%实现fc振荡(在一个周期内)
CI4=cos(2*pi*f1*t+2*pi*f1*(n-1)*Ts+pi.*7/4);%实现fc振荡(在一个周期内)
%----------------------调制的初始设定-------------------------------
if source(n)==0;
y((n-1)*20+1:n*20)=CI1;
end
if source(n)==1;
y((n-1)*20+1:n*20)=CI2;
end
if source(n)==2;
y((n-1)*20+1:n*20)=CI3;
end
if source(n)==3;
y((n-1)*20+1:n*20)=CI4
end
%------------------------------------------------------------------
figure(1)
subplot(2,1,1)
title('调制信号')
plot(t,y((n-1)*20+1:n*20))%画出调制信号的波形
hold on;
grid on;
n=n+1;%实现连续取值
end
subplot(2,1,2);
stem(K,source);
title('数字信号source')%数字信号的表示
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -