MATLAB-FM调制

MATLAB-FM调制,matlab,signal-processing,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); 它可以显示第一个打印命令,但不能显示第二个。它抛出

我试图用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);

它可以显示第一个打印命令,但不能显示第二个。它抛出一个错误:
第10行第5列附近的'fmmod'未定义。上述代码有什么问题?

以下功能将生成调频调制信号-它不如
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
函数类似的参数调用它(但不带可选参数):


让我知道这对您是如何起作用的。

我想这是更简单的方法


您在哪里/如何定义
fmmod
?我猜您没有通信系统工具箱。正如Doresoom指出的,您可能没有通信系统工具箱,而
fmmod
是其中的一部分。您可以通过在MATLAB命令行中键入
ver
来检查您有哪些工具箱。另外,请考虑
fmmod
中的
fs
是采样率,而不是信号频率。您应该使用大于
2*fc
(奈奎斯特标准)的采样率@Doresoom,我有通信系统工具箱。
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);
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;