MATLAB - FM调制

时间:2013-09-30 15:13:57

标签: matlab signal-processing

我正在尝试使用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);

能够显示第一个绘图命令,但不能显示第二个绘图命令。它抛出一个错误:`fmmod' undefined near line 10 column 5。上面的代码有什么问题?

2 个答案:

答案 0 :(得分:2)

以下函数将生成FM调制信号 - 它不如fmmod那么好(灵活等),但如果您没有Comm System Toolbox,这可能是一个不错的选择。

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);

让我知道这对你有用。

答案 1 :(得分:0)

我想这是更简单的方法 的

clc;
clear all;
close all;
fm=input('Message Frequency=');
fc=input('Carrier Frequency=');
mi=input('Modulation Index=');
t=0:0.0001:0.1;
m=sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;

c=sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier Signal');
grid on;

y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));%Frequency changing w.r.t Message
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
title('FM Signal');
grid on;

相关问题