0% found this document useful (0 votes)
23 views10 pages

AM and FM Signal Analysis in MATLAB

This report details the synthesis and analysis of amplitude modulation (AM) and frequency modulation (FM) signals using MATLAB, focusing on beat notes and chirp signals. It includes code for generating beat and chirp signals, visualizations of their time-domain waveforms, and frequency analysis through spectrograms, highlighting the effects of window length on frequency resolution. The findings demonstrate the relationship between time-domain waveforms and their frequency-domain representations, including the impact of negative frequencies in chirp signals.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

AM and FM Signal Analysis in MATLAB

This report details the synthesis and analysis of amplitude modulation (AM) and frequency modulation (FM) signals using MATLAB, focusing on beat notes and chirp signals. It includes code for generating beat and chirp signals, visualizations of their time-domain waveforms, and frequency analysis through spectrograms, highlighting the effects of window length on frequency resolution. The findings demonstrate the relationship between time-domain waveforms and their frequency-domain representations, including the impact of negative frequencies in chirp signals.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lab 2: AM and FM Sinusoidal Signals - Section 4

Report

Harold Kekeli Dagadu 7096521

June 19, 2025

Introduction
This report addresses Section 4 of Lab 2, focusing on synthesizing and analyzing
amplitude modulation (AM) and frequency modulation (FM) signals, specifically
beat notes and chirp signals. We use MATLAB to generate these signals, visualize
their time-domain waveforms, and analyze their frequency content using spectro-
grams. The report includes code listings for the beat.m and mychirp.m functions,
plots with labeled axes and titles, and explanations connecting the time-domain sig-
nals to their frequency-domain representations. The tasks include generating beat
signals, exploring spectrogram window length effects, and analyzing chirp signals
with linear frequency sweeps, including one with a negative end frequency.

1 Beat Notes
1.1 (a) Beat Signal Function
The beat.m function generates a beat signal by summing two cosine waves with
frequencies fc − f∆ and fc + f∆ . Below is the MATLAB code:
1 function [xx, tt] = beat(A, B, fc, delf, fsamp, dur)
2 % BEAT compute samples of the sum of two cosine waves
3 % [xx, tt] = beat(A, B, fc, delf, fsamp, dur)
4 % A = amplitude of lower frequency cosine
5 % B = amplitude of higher frequency cosine
6 % fc = center frequency (Hz)
7 % delf = frequency difference (Hz)
8 % fsamp = sampling rate (Hz)
9 % dur = total time duration in seconds
10 % xx = output vector of samples
11 % tt = time vector corresponding to xx
12

1
13 % Create time vector
14 dt = 1 / fsamp;
15 tt = 0:dt:dur;
16

17 % Compute the two frequencies


18 f1 = fc - delf; % Lower frequency
19 f2 = fc + delf; % Higher frequency
20

21 % Generate the beat signal


22 xx = A * cos(2 * pi * f1 * tt) + B * cos(2 * pi * f2 * tt);
23 end

This function takes amplitudes A and B, center frequency fc , frequency difference


f∆ , sampling rate fs , and duration dur, returning the signal samples xx and time
vector tt.

1.2 (b) Testing the Beat Signal


We tested the beat.m function with parameters A = 10, B = 10, fc = 1000 Hz, f∆ =
10 Hz, fs = 11025 Hz, and dur = 1 sec. The first 0.2 seconds of the signal were plotted
using the following code:
1 % Parameters
2 A = 10; B = 10; fc = 1000; delf = 10; fsamp = 11025; dur = 1;
3

4 % Generate beat signal


5 [xx, tt] = beat(A, B, fc, delf, fsamp, dur);
6

7 % Plot first 0.2 seconds


8 figure;
9 plot(tt(tt ¡= 0.2), xx(tt ¡= 0.2));
10 xlabel(’Time (seconds)’);
11 ylabel(’Amplitude’);
12 title(’Beat Signal: fc = 1000 Hz, f˙“Delta = 10 Hz, First 0.2 Seconds’)
;
13 grid on;
14

15 % Play sound
16 soundsc(xx, fsamp);

Waveform Properties:
• Envelope Period: The envelope is governed by cos(2πf∆ t), where f∆ = 10 Hz.
The period is:
1 1
Tenvelope = = = 0.1 seconds
f∆ 10

2
Figure 1: Beat signal over the first 0.2 seconds, showing oscillations at 1000 Hz with
an envelope period of 0.1 seconds.

This is observed as the time between amplitude peaks (e.g., from t = 0 to t =


0.1 sec).
• Carrier Period: The high-frequency oscillations are at fc ≈ 1000 Hz, with a
period of:
1 1
Tcarrier = = = 0.001 seconds
fc 1000
Zooming in on the plot reveals oscillations every 0.001 seconds.
Explanation: The beat signal results from interference between two close frequen-
cies (990 Hz and 1010 Hz), producing an amplitude-modulated waveform. The en-
velope’s period corresponds to f∆ , reflecting the beating effect, while the carrier’s
rapid oscillations are centered around fc . The sound has a pulsating quality due to
this modulation.

2 More on Spectrograms
2.1 (a) Beat Signal Generation
We generated a beat signal with parameters A = 10, B = 10, fc = 2000 Hz, f∆ = 32 Hz,
fs = 11025 Hz, and dur = 0.26 sec:
1 % Parameters
2 A = 10; B = 10; fc = 2000; delf = 32; fsamp = 11025; dur = 0.26;
3

4 % Generate beat signal

3
5 [xx, tt] = beat(A, B, fc, delf, fsamp, dur);
6

7 % Plot signal
8 figure;
9 plot(tt, xx);
10 xlabel(’Time (seconds)’);
11 ylabel(’Amplitude’);
12 title(’Beat Signal: fc = 2000 Hz, f˙“Delta = 32 Hz’);
13 grid on;

Figure 2: Beat signal over 0.26 seconds, showing oscillations at 2000 Hz with an
envelope period of 0.03125 seconds.

2.2 (b) Spectrogram with Window Length 2048


We computed the spectrogram using a window length of 2048 samples:
1 % Spectrogram with window length 2048
2 figure;
3 specgram(xx, 2048, fsamp);
4 colormap(1 - gray(256));

4
5 colorbar;
6 title(’Spectrogram of Beat Signal (Window = 2048)’);
7 xlabel(’Time (seconds)’);
8 ylabel(’Frequency (Hz)’);

Hz.
Hz.
Figure 3: Spectrogram of beat signal with 2048-sample window, showing lines at
1968 Hz and 2032 Hz
Hz.

Comments: The 2048-sample window (duration 2048/11025 ≈ 0.186 sec) provides


high frequency resolution, clearly separating the two frequency components (1968
Hz and 2032 Hz) as distinct horizontal lines. The spectrogram confirms the presence
of the correct frequencies, with minimal smearing in time due to the long window.

2.3 (c) Spectrogram with Window Length 16


We computed the spectrogram using a window length of 16 samples:
1 % Spectrogram with window length 16
2 figure;

5
3 specgram(xx, 16, fsamp);
4 colormap(1 - gray(256));
5 colorbar;
6 title(’Spectrogram of Beat Signal (Window = 16)’);
7 xlabel(’Time (seconds)’);
8 ylabel(’Frequency (Hz)’);

Figure 4: Spectrogram of beat signal with 16-sample window, showing a broad band
around 2000 Hz with intensity variations.

Comments: The 16-sample window (duration 16/11025 ≈ 0.00145 sec) has poor fre-
quency resolution, unable to distinguish 1968 Hz from 2032 Hz, showing a single
broad band around 2000 Hz. However, it captures the envelope’s 32 Hz oscillation
as intensity variations. This illustrates the time-frequency trade-off: longer win-
dows improve frequency resolution but lose temporal detail, while shorter win-
dows track time changes but blur frequencies.
Explanation: The beat signal’s time-domain waveform shows amplitude modula-
tion due to the 32 Hz difference frequency, evident in the 16-sample spectrogram’s
intensity variations. The 2048-sample spectrogram resolves the two frequencies,
confirming the signal’s composition.

6
3 Spectrogram of a Chirp
3.1 Chirp Signal Function
The mychirp.m function generates a linear-FM chirp signal with a frequency that
changes from f1 to f2 :
1 function [xx, tt] = mychirp(f1, f2, dur, fsamp)
2 % MYCHIRP generate a linear-FM chirp signal
3 % [xx, tt] = mychirp(f1, f2, dur, fsamp)
4 % f1 = starting frequency (Hz)
5 % f2 = ending frequency (Hz)
6 % dur = total time duration (seconds)
7 % fsamp = sampling frequency (Hz, default: 11025)
8

9 if nargin ¡ 4
10 fsamp = 11025;
11 end
12

13 % Create time vector


14 dt = 1 / fsamp;
15 tt = 0:dt:dur;
16

17 % Linear frequency change: f(t) = f1 + (f2 - f1) * (t / dur)


18 % Phase psi(t) = integral of 2 * pi * f(t) dt
19 mu = (f2 - f1) / (2 * dur); % Rate of frequency change
20 psi = 2 * pi * (mu * tt.ˆ2 + f1 * tt);
21 xx = cos(psi); % Amplitude = 1
22 end

3.2 Chirp Generation and Analysis


We generated a chirp signal with f1 = 5000 Hz, f2 = 300 Hz, dur = 3 sec, and fs =
11025 Hz:
1 % Parameters
2 f1 = 5000; f2 = 300; dur = 3; fsamp = 11025;
3

4 % Generate chirp signal


5 [xx, tt] = mychirp(f1, f2, dur, fsamp);
6

7 % Play sound
8 soundsc(xx, fsamp);
9

10 % Generate spectrogram
11 figure;
12 specgram(xx, 1024, fsamp);

7
13 colormap(1 - gray(256));
14 colorbar;
15 title(’Spectrogram of Chirp: 5000 Hz to 300 Hz’);
16 xlabel(’Time (seconds)’);
17 ylabel(’Frequency (Hz)’);

Figure 5: Spectrogram of chirp signal, showing a linear sweep from 5000 Hz to 300
Hz over 3 seconds.

Comments: The sound is a “chirp down,” with the pitch decreasing linearly from
5000 Hz to 300 Hz, resembling a descending siren. The instantaneous frequency is:
300 − 5000
fi (t) = 5000 + · t = 5000 − 1566.67t
3
The spectrogram shows a linear downward slope from 5000 Hz to 300 Hz, validating
the mychirp function.
Explanation: The chirp’s quadratic phase in the time domain produces a linear
frequency sweep, visualized as a sloping line in the frequency-domain spectrogram.

8
4 A Chirp Puzzle
We generated a chirp signal with f1 = 3000 Hz, f2 = −2000 Hz, dur = 3 sec, and
fs = 11025 Hz:
1 % Parameters
2 f1 = 3000; f2 = -2000; dur = 3; fsamp = 11025;
3

4 % Generate chirp signal


5 [xx, tt] = mychirp(f1, f2, dur, fsamp);
6

7 % Play sound
8 soundsc(xx, fsamp);
9

10 % Generate spectrogram
11 figure;
12 specgram(xx, 1024, fsamp);
13 colormap(1 - gray(256));
14 colorbar;
15 title(’Spectrogram of Chirp: 3000 Hz to -2000 Hz’);
16 xlabel(’Time (seconds)’);
17 ylabel(’Frequency (Hz)’);

Comments: The sound chirps down from 3000 Hz to 0 Hz at t ≈ 1.8 sec, then chirps
up to 2000 Hz. The instantaneous frequency is:
−2000 − 3000
fi (t) = 3000 + · t = 3000 − 1666.67t
3
Since cos(2π(−f )t) = cos(2πf t), negative frequencies are perceived as positive, caus-
ing the frequency to increase in magnitude after reaching 0 Hz. The spectrogram
shows a V-shaped pattern, reflecting |fi (t)|.
Explanation: The chirp’s quadratic phase causes the frequency to decrease through
zero to negative values. The spectrogram displays only positive frequencies, show-
ing the absolute frequency trajectory.

5 Discussion
The beat signal’s time-domain waveform (Section 4.1) shows amplitude modulation
due to interference between two close frequencies, with the envelope period deter-
mined by f∆ and the carrier by fc . The spectrograms in Section 4.2 illustrate the
time-frequency trade-off: the 2048-sample window resolves 1968 Hz and 2032 Hz
but blurs temporal changes, while the 16-sample window captures the 32 Hz enve-
lope but merges frequencies. The chirp signals (Sections 4.3 and 4.4) have quadratic

9
Figure 6: Spectrogram of chirp signal, showing a V-shaped pattern from 3000 Hz to
0 Hz and back to 2000 Hz.

phases, producing linear frequency sweeps, visualized as sloping lines in spectro-


grams. The negative frequency in Section 4.4 results in a V-shaped spectrogram due
to the real-valued signal’s symmetry.

10

You might also like