我正在尝试使用Matlab对正弦信号进行频率调制。为此,我编写了以下代码:
fc = 5000; %Carrier Frequency
fs = 1000; %Signal Frequency
t = 0:0.00001:0.002;
x = sin(2*pi*fs*t);
dev = 50;
subplot(2,1,1);
plot(t,x);
y = fmmod(x,fc,fs,dev);
subplot(2,1,2);
plot(t,y);它可以显示第一个plot命令,但不能显示第二个命令。它抛出一个错误:`fmmod' undefined near line 10 column 5。上面的代码有什么问题?
发布于 2013-10-01 01:19:23
以下功能将生成FM调制信号-它不如fmmod好(灵活等),但如果您没有通信系统工具箱,这可能是一个很好的替代方案。
function [s t] = makeFM( x, Fc, Fs, strength )
% for a signal x that modulates a carrier at frequency Fc
% produce the FM modulated signal
% works for 1 D input only
% no error checking
x = x(:);
% sampling points in time:
t = ( 0 : numel( x ) - 1 )' / Fs;
% integrate input signal
integratedX = cumsum( x ) / Fs;
s = cos( 2 * pi * ( Fc * t + strength * integratedX )); 将其放入您的路径中,并使用与fmmod函数类似的参数调用它(但没有可选参数):
fc = 5000; %Carrier Frequency
fs = 1000; %Signal Frequency
t = 0:0.00001:0.002;
x = sin( 2*pi*fs*t );
dev = 50;
subplot(2,1,1);
plot(t,x);
y = makeFM(x, fc, 2.5*fc, dev); % note sampling frequency must be > carrier frequency!
subplot(2,1,2);
plot(t,y);让我知道这是如何为你工作的。
https://stackoverflow.com/questions/19097771
复制相似问题