MATLAB-FM调制 [英] MATLAB - FM Modulation

查看:320
本文介绍了MATLAB-FM调制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Matlab频率调制正弦信号.我为相同的代码编写了以下代码:

I am trying to Frequency modulate a sine signal using Matlab. I have written the following code for the same:

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.上面的代码有什么问题?

It is able to display the first plot command but not the second one. It throws an error: `fmmod' undefined near line 10 column 5. What is wrong in the above code?

推荐答案

以下函数将生成FM调制信号-不如fmmod那样好(灵活等),但是如果您没有Comm System工具箱可能是一个很好的选择.

The following function will generate a FM modulated signal - it's not as good (flexible, etc) as fmmod but if you don't have the Comm System Toolbox this may be a good alternative.

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函数相似的参数调用它(但不包含可选参数):

Put this in your path and call it with similar arguments to the fmmod function (but without optional parameters):

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

让我知道它如何为您工作.

Let me know how that works for you.

这篇关于MATLAB-FM调制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆