我在八度音程中使用了以下代码来实现具有正弦信息和方波载波的频率调制。
%script to make a squarewave carrier modulated with a sinusoidal message
fmsg=1; %Message signal frequency. 1 Hz
fc=10; %carrier frequency, 10 Hz
Fs=200; %sampling frequency, 200 Hz
t=[0:1/Fs:3/fmsg]; %Time duaration defined
%The message signal
x=2.*sin(2*pi*fmsg*t);
subplot(3,1,1); plot(t,x); title('Message')
%The carrier signal
y=5.*square(2*pi*fc*t);
subplot(3,1,2);plot(t,y); title('Carrier')
%steps for FM modulation
x_max=max(x);
x_modulating=x./x_max; %x_modulating is normalized to unity
fdev=x_modulating*fc/2; %finding frequency deviation corresponding to a maximum of 50% deviation from the carrier frequency
fc=fc*ones(size(t)); %making the size of fc and fdev the same so that they can be added
z=5.*square(2*pi*((fc+fdev).*t)); %Generating FM signal
subplot(3,1,3);plot(t,z);title('FM');
print('fm.png');
但合成的FM波形的频率与消息信号幅度不成比例。可能是什么原因。怎么可以解决?
答案 0 :(得分:0)
从wikipedia开始,FM信号的相位与瞬时频率的积分成正比,这与瞬时频率与运行时间相乘并不完全相同。
可以通过修改您提供的代码的最后部分来实现简单的阶段集成,例如:
% fc = fc*one(size(t)); % will use scalar fc for all i below
phase = 0;
for i=1:size(t,2)
z(i) = 5.*square(phase);
phase = mod(phase + 2*pi*(fc+fdev(i))/Fs, 2*pi);
endfor
请注意,由于调制信号在采样周期内变化,因此可以与梯形规则积分器进行更精确的集成,但对于大多数应用来说,上述内容应该足够了。