**frequency modulation (FM) in MATLAB**? Before that we must know

**what is FM (frequency modulation)**. In FM, frequency of the carrier signal having high frequency is varied in accordance with the instantaneous amplitude of the modulating signal having low frequency. Frequency modulated signals are widely used in television and radio transmission systems. FM signals can be easily plotted using simple MATLAB functions. The MATLAB code is shown below, the use of particular code is also given as commented form ( %Comment field ). The given matlab program is capable of accepting two input frequencies and modulation index from the user.

**Also see:**

- MATLAB code for Amplitude modulation (AM) with modulation index
- Phase Shift Keying (PSK) modulation in matlab

## Mathematical representation of FM Signal

Let the modulating signal be

and the carrier signal be

then the modulating signal e(t) is expressed as

where ‘m’ is the modulation index.

## MATLAB Codes

[cc lang=”Matlab”]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;

[/cc]

Thank you so much man, it is so helpful 😀

yes very much………… Thanks

thanks …it was useful…can I have a program for fm reciver with superhetrodyne architecture

Watch out! Code above isn’t quite right, you have to use integration. Below the right one:

Ac = 1;

fc = 10;

Amod = 0.5;

fmod = 1.5;

kf = 15;

syms x

mod(x) = Amod*sin(2*pi*fmod*x);

sfm(x) = Ac*cos(2*pi*fc*x + 2*pi*kf*int(mod,x,0,x));

t = 0:1/1000:2;

hold off

plot(t,sfm(t),’k’);

hold on;

plot(t,mod(t),’r’);

Thanks José, the code above was obviously for Phase-Modulation (PM).

hey…dats a nice thing….but as I am new to matlab…I don’t know abt the functions…I have got a project on fm modulation…so plz tell me the meaning of each line and heir function as the comments provided are not worth..plz help me out asap….thnku…

Hi amandeep kaur,

Really sorry Mr.amandeep kaur, due to large volume of comments and email I could not able to explain simple basic things. The commands used in the above program are extreme basic and you may get more information by Google search for it.

Hello, your code is great, just one issue, the modulation formula used is for a cossine modulator signal.

can i get a MATLAB program on

SIMULATION OF COMPARISON BETWEEN AM & FM…???

Also for

ENCRYPTION OF A FILE USING STANDARD ALGORITHM … by ceaser cipher method

The code above is complete false.

Its pretty weird to see how people doesnt understand at all how a frequency modulator works.

Im sorry but what you did is an apparent phase modulator.

In a frequency modulator, the modulating signal corresponds to the instantaneous frequency and not to the phase.

The instantaneous frequency is obtained by derivating the phase.

You miss an integration in your code.

….

Hi

I want calculate bandwidth of voice signal that modulation with fm modulator please help me.

I would like to ask you have you ever done Frequency modulation (FM) by using Simulink?

I need a demodulation formula

I agree with José Lima

Your code is actually for PM (phase modulation)

hello ,

if I want to meke FM . PM . AM

that receve my voice and then make me hear what I said how ??