?? 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 + -