# MATLAB MATLAB - frequency modulation, need some help

#### atlbraves49

Ok I am trying to solve this problem, I will lay it out, then say what I've done so far, and I would appreciate if someone could help me figure out where I am going wrong. I am very new to MATLAB (using it for the first time) so I've only got the basics down so far.

Problem:

Message signal
m(t) = t for 0<=t<1
= -t+2 for 1 <= t < 2
= 0 otherwise

frequency modulates the carrier c(t)=cos(2*pi*fc*t), when fc=1000Hz. The frequency-deviation constant is kf=25.

1.) Plot the message signal and its integral on two separate graphs.

my code:

fc=1000;
kf=25;
ts=0.0001;
fs=1/ts;
df=0.25;

t0 = -1:0.01:0;
m0 = zeros(size(t0));
t1 = 0:0.01:1;
m1 = t1;
t2 = 1:0.01:2;
m2 = -t2 +2;
t = [t0 t1 t2]; % create t and m
m = [m0 m1 m2];
plot(t,m) % plot m(t)
grid % add grid and labels to plot
xlabel('t')
title('M(t) Message Signal')

Integral code... (which i think is wrong..)

clear plot
t0 = -1:0.01:0;
im0 = zeros(size(t0));
t1 = 0:0.01:1;
im1 = t1.^2/2;
t2 = 1:0.01:2;
im2 = -t2.^2/2+2*t2;
t = [t0 t1 t2]; % create t and integral of m
im = [im0 im1 im2];
plot(t,im) % plot integral of m
grid % add grid and labels to plot
xlabel('t')
title('Integral of M(t) Message Signal')
2) Plot the FM signal
http://img31.imageshack.us/img31/7428/equation.jpg [Broken]

my code (which gives a funky picture leading me to believe that my integral code is wrong)

u=cos(2*pi*fc*t+2*pi*kf*im);
plot(t,u(1:length(t)))
title('u(t)')
grid
xlabel('t')
3) Use MATLAB's Fourier-Transform routine to compute and plot the spectra of m(t) and u(t) on separate graphs.

Unsure what to do for these

4) Determine the modulation index, the bandwidth, and the range of the instantaneous frequency of u(t)

Last edited by a moderator:
Related Math Software Workshop News on Phys.org

"MATLAB - frequency modulation, need some help"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving