MATLAB - frequency modulation, need some help

In summary: U)))/(2*pi*ts); % calculate the instantaneous frequencyplot(t(1:length(inst_freq)),inst_freq);title('Instantaneous Frequency of u(t)');xlabel('Time (sec)');ylabel('Frequency (Hz)');grid;min_freq = min(inst_freq); % minimum frequencymax_freq = max(inst_freq); % maximum frequencyIn summary, you are trying to solve a problem involving frequency modulation in MATLAB. You need to plot the message signal and its integral, plot the FM signal using the correct formula, compute and plot the spectra of the message signal and FM signal, and determine the modulation index, bandwidth, and range of the instantaneous frequency.
  • #1
atlbraves49
81
0
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

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)

not sure about these, suggestions?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2


Hello,

I can help you with your problem. Let's break it down step by step and see where you might have gone wrong.

1) Plotting the message signal and its integral on separate graphs: Your code for plotting the message signal looks correct, but your code for the integral needs a few adjustments. Instead of using the t variable for the integral, you should use a new variable, let's call it "tau." Also, instead of using the square function (^2), use the power function (t.^2). Finally, you should multiply the integral by the frequency deviation constant (kf) to get the correct scaling. Your integral code should look like this:

tau = [t0 t1 t2];
im = [im0 im1 im2];
im = kf*im.*tau.^2/2;

2) Plotting the FM signal: Again, you need to use the correct variable for the integral. Also, make sure to use the correct formula for the FM signal, which is u = cos(2*pi*fc*t + 2*pi*kf*im). Your code should look like this:

u = cos(2*pi*fc*t + 2*pi*kf*im);
plot(t,u(1:length(t)));
title('u(t)');
grid;
xlabel('t');

3) Fourier transform: To compute the spectra of m(t) and u(t), you can use the "fft" function in MATLAB. Your code should look like this:

M = fft(m);
U = fft(u);
freq = linspace(-fs/2,fs/2,length(m)); % create frequency axis
plot(freq,abs(fftshift(M))); % plot the spectra of m(t)
title('Spectrum of m(t)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid;

plot(freq,abs(fftshift(U))); % plot the spectra of u(t)
title('Spectrum of u(t)');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid;

4) Modulation index, bandwidth, and range of the instantaneous frequency: To determine the modulation index, you can use the formula kf*max(m(t)). The bandwidth of the FM signal is equal to 2*(kf + max(m(t))). The range of the instantaneous frequency can be determined by plotting the instantaneous frequency of u(t) over time and finding the maximum and minimum values. Your code should look like this:

mod_index = kf*max(m);
bandwidth
 
  • #3

Hello, it looks like you are trying to solve a problem involving frequency modulation using MATLAB. I can provide some guidance and suggestions to help you with your code.

1) For plotting the message signal and its integral, your code looks correct. However, you could simplify it by using the "if" statement to define the message signal instead of creating separate arrays for each piece. For example:

t = -1:0.01:2; % create t from -1 to 2 with a step size of 0.01
m = zeros(size(t)); % initialize m as an array of zeros with the same size as t
m(t>=0 & t<1) = t(t>=0 & t<1); % define the message signal for t between 0 and 1
m(t>=1 & t<2) = -t(t>=1 & t<2)+2; % define the message signal for t between 1 and 2
plot(t,m) % plot m(t)
grid % add grid and labels to plot
xlabel('t')
title('M(t) Message Signal')

For the integral, you can use the "cumtrapz" function to calculate the integral of the message signal. For example:

im = cumtrapz(t,m); % calculate the integral of m using the cumtrapz function
plot(t,im) % plot the integral
grid % add grid and labels to plot
xlabel('t')
title('Integral of M(t) Message Signal')

2) For plotting the FM signal, your code is close but you need to use the correct variables. Also, since the FM signal is a continuous function, you can use a smaller step size for t to get a smoother plot. For example:

u = cos(2*pi*fc*t+2*pi*kf*im); % calculate the FM signal using the message signal's integral
plot(t,u) % plot the FM signal
title('u(t)')
grid
xlabel('t')

3) To use MATLAB's Fourier-Transform routine, you can use the "fft" function. For example:

M = fft(m); % calculate the Fourier transform of the message signal
U = fft(u); % calculate the Fourier transform of the FM signal
f = (0:length(t)-1)*fs/length(t); % create a frequency vector
plot(f,abs(M)) % plot the magnitude of the Fourier transform of m
 

What is frequency modulation (FM) in MATLAB?

Frequency modulation is a technique used to alter the frequency of a signal in MATLAB. It involves varying the frequency of a signal based on the information being transmitted, resulting in a modulated signal with a varying frequency. This technique is commonly used in communication systems to transmit data.

How is frequency modulation implemented in MATLAB?

In MATLAB, frequency modulation can be implemented using the "fmmod" function. This function takes in the input signal, carrier frequency, and modulation index as parameters to produce the modulated signal. The "fmdemod" function can then be used to demodulate the signal back to its original form.

What are the advantages of frequency modulation in MATLAB?

Frequency modulation in MATLAB offers several advantages over other modulation techniques. It provides better noise immunity, higher bandwidth efficiency, and better signal quality. Additionally, it allows for the transmission of multiple signals simultaneously using different carrier frequencies.

What are the applications of frequency modulation in MATLAB?

Frequency modulation in MATLAB has various applications in communication systems, such as radio broadcasting, television broadcasting, and satellite communication. It is also used in radar systems for target detection and tracking and in medical imaging techniques like magnetic resonance imaging (MRI).

What are the limitations of frequency modulation in MATLAB?

Although frequency modulation has many advantages, it also has some limitations. One of the main limitations is its susceptibility to frequency drift and interference, which can affect the quality of the modulated signal. Additionally, it requires a larger bandwidth compared to other modulation techniques, making it less efficient for use in crowded frequency bands.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
978
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
203
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
735
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
925
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top