How to generate

**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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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; |

## Generated FM Signal

Message Frequency=25

Carrier Frequency=400

Modulation Index=10

Hope this matlab program was helpful to you. Similarly you can find out the codes for ASK, PWM etc in this website. Also we will come up with more. So keep visiting and let us know your views through the comment boxes below.

Thank you so much man, it is so helpful

yes very much………… Thanks

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

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.