www.pudn.com > PCMsheji.rar > FM.M


% 频率调制到MATLAB演示程序。消息信号 
% 当 0 < t < t0/3为+1, 当t0/3 < t < 2t0/3 时为-2,其它情况下为0。 
echo off 
clear all 
close all 
t0=.15; % 信号到持续时间 
ts=0.0005; % 抽样间隔 
fc=200; % 载波频率 
kf=50; % 偏移常数 
fs=1/ts; % 抽样频率 
t=[0:ts:t0]; % 时间向量 
df=0.25; % 所需频率分辨率 
% message signal 
x=ones(1,t0/(3*ts)); 
y=zeros(1,t0/(3*ts)+1); 
m=[x,(-2)*x,y]; 
int_m(1)=0; 
for i=1:length(t)-1  % m的积分 
  int_m(i+1)=int_m(i)+m(i)*ts; 
end 
[M,m,df1]=fftseq(m,ts,df); % 傅立叶变换 
M=M/fs; % 缩放 
f=[0:df1:df1*(length(m)-1)]-fs/2; % 频率向量 
u=cos(2*pi*fc*t+2*pi*kf*int_m); % 调制信号 
[U,u,df1]=fftseq(u,ts,df); % 傅立叶变换  
U=U/fs; % 缩放 
waitx=input('按任意键显示消息信号和调制信号'); 
figure(1) 
subplot(2,1,1) 
plot(t,m(1:length(t))) 
axis([0 0.15 -2.1 2.1]) 
xlabel('Time') 
title('The message signal') 
subplot(2,1,2) 
plot(t,u(1:length(t))) 
axis([0 0.15 -2.1 2.1]) 
xlabel('Time') 
title('The modulated signal') 
waitx=input('按任意键显示消息信号和调制信号的功率谱'); 
figure(2) 
subplot(2,1,1) 
plot(f,abs(fftshift(M)))  
xlabel('Frequency') 
title('Magnitude-spectrum of the message signal') 
subplot(2,1,2) 
plot(f,abs(fftshift(U)))  
title('Magnitude-spectrum of the modulated signal') 
xlabel('Frequency')