简体   繁体   English

MATLAB-FM调制

[英]MATLAB - FM Modulation

I am trying to Frequency modulate a sine signal using Matlab. 我正在尝试使用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);

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 . 它将引发错误: `fmmod' undefined near line 10 column 5 What is wrong in the above code? 上面的代码有什么问题?

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. 以下函数将生成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 ));   

Put this in your path and call it with similar arguments to the fmmod function (but without optional parameters): 将其放在您的路径中,并使用与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);

Let me know how that works for you. 让我知道这对您有用。

I guess this is more simple approach 我想这是更简单的方法

 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 wrt Message subplot(3,1,3); plot(t,y); xlabel('Time'); ylabel('Amplitude'); title('FM Signal'); grid on; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM