?? fm.asv
字號(hào):
close all
t0=8; %信號(hào)的持續(xù)時(shí)間,用來(lái)定義時(shí)間軸的取值范圍
ts=0.0001; %抽樣間隔
fs=1/ts; %抽樣頻率
fc=10000; %載波頻率
t=[-t0/2:ts:t0/2]; %時(shí)間軸的取值
kf=5; %壓控振蕩系數(shù)
df=0.25; %所需的頻率分辨率,用在求傅里葉變換時(shí),它表示FFT的最小頻率間隔
m=2*pi*t; %調(diào)制信號(hào)
%*********************************************************************
jifen(1)=0; %求信號(hào)m(t)的積分
for i=1:length(t)-1
jifen(i+1)=jifen(i)+m(i)*ts;
end
%*********************************************************************
[M,m,df1]=fourier(m,ts,df); %對(duì)調(diào)制信號(hào)m(t)求傅里葉變換,需調(diào)用子函數(shù)fourier
M=M/fs; %縮放,便于在頻譜圖上整體觀察
f=[1:length(m)]-fs/2; %時(shí)間軸上對(duì)應(yīng)的頻率向量
u=1.414*cos(2*pi*fc*t+2*pi*kf*jifen); %調(diào)制后的信號(hào)
[U,u,df1]=fourier(u,ts,df); %對(duì)調(diào)制后的信號(hào)u(t)求傅里葉變換
U=U/fs; %縮放
%*********************************************************************
t1=[0:ts:ts*(length(u)-1)]; %對(duì)已調(diào)信號(hào)進(jìn)行解調(diào)
z=hilbert(u); %希爾伯特變換
yq =z.*exp(-j*2*pi*fc*t1);
dem =diff(unwrap(angle(yq))*fs)/(2*pi*kf);
%unwrap函數(shù)用于恢復(fù)相位并去掉2π相位疊加的影響
for i=1:(length(t)-1)/2
dem(i)=-dem(i);
end
%*********************************************************************
figure(1)
subplot(2,1,1)
plot(t,m(1:length(t))) %此時(shí)的m信號(hào)是重新構(gòu)建的信號(hào),
%因?yàn)樵趯?duì)m求傅里葉變換時(shí)m=[m,zeros(1,n-n2)]
xlabel('時(shí)間t')
title('調(diào)制信號(hào)的時(shí)域波形')
subplot(2,1,2)
plot(t,u(1:length(t)))
axis([-1.5,1.5,-1.5,1.5]);
xlabel('時(shí)間t')
title('已調(diào)信號(hào)的時(shí)域波形')
figure(2)
subplot(2,1,1)
plot(f,abs(fftshift(M))) %fftshift:將FFT中的DC分量移到頻譜中心
axis([58000,63000,0,2]);
xlabel('頻率f')
title('調(diào)制信號(hào)的頻譜圖')
subplot(2,1,2)
plot(f,abs(fftshift(U)))
axis([58000,63000,0,0.5]);
xlabel('頻率f')
title('已調(diào)信號(hào)的頻譜圖')
figure(3)
subplot(2,1,1)
plot(t,m(1:length(t)))
xlabel('時(shí)間t')
title('調(diào)制信號(hào)的時(shí)域波形')
subplot(2,1,2)
plot(t,dem(1:length(t)))
axis([-t0/2,t0/2,-t0*5,t0*5]);
xlabel('時(shí)間t')
title('解調(diào)信號(hào)的時(shí)域波形')
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -