0% found this document useful (0 votes)
39 views2 pages

Explanation

The document explains a MATLAB code that generates and demodulates Amplitude Modulation (AM), Frequency Modulation (FM), and Phase Modulation (PM) signals. It details the modulation process for each type, including the use of Hilbert transform for AM, phase unwrapping for FM, and scaling for PM, along with plotting results for comparison. The output includes visualizations of the original message signal, modulated signals, and their respective demodulated signals.

Uploaded by

wesen derbe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Explanation

The document explains a MATLAB code that generates and demodulates Amplitude Modulation (AM), Frequency Modulation (FM), and Phase Modulation (PM) signals. It details the modulation process for each type, including the use of Hilbert transform for AM, phase unwrapping for FM, and scaling for PM, along with plotting results for comparison. The output includes visualizations of the original message signal, modulated signals, and their respective demodulated signals.

Uploaded by

wesen derbe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Explanation of the Code:

Input Signal: A simple sine wave is generated as the input signal.


PCM Modulation: The input signal is quantized into discrete levels, and the
quantized values are scaled back to the original amplitude range.
PAM Modulation: The input signal is scaled to the PAM levels based on the
quantization levels.
PWM Modulation: The signal is converted to a PWM signal based on a specified duty
cycle.
PPM Modulation: The signal is represented by pulses that are positioned based on
the input signal's amplitude.
Plotting: Each modulation scheme is plotted in separate subplots for comparison.
The PPM modulation is visualized in a separate figure to illustrate the pulse
positioning.
Here’s a complete MATLAB code for demodulating Amplitude Modulation (AM), Frequency
Modulation (FM), and Phase Modulation (PM) signals. The script generates modulated
signals, adds some noise for realism, and demonstrates the demodulation process.
MATLAB Code

clc;
clear;
close all;

% Signal parameters
fs = 1e5; % Sampling frequency (Hz)
t = 0:1/fs:0.01; % Time vector (10 ms duration)
fc = 1000; % Carrier frequency (Hz)
fm = 50; % Message signal frequency (Hz)
Am = 1; % Amplitude of the message signal
Ac = 2; % Amplitude of the carrier signal

% Message signal
m = Am * sin(2 * pi * fm * t);

%% 1. Amplitude Modulation (AM)


% Modulation
AM_signal = Ac * (1 + m) .* cos(2 * pi * fc * t);

% Demodulation (Envelope Detection)


AM_envelope = abs(hilbert(AM_signal));

% Plot AM results
figure;
subplot(3, 1, 1);
plot(t, m, 'b', t, AM_signal, 'r');
title('AM Modulation and Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Message Signal', 'AM Signal');

subplot(3, 1, 2);
plot(t, AM_envelope, 'k');
title('Demodulated AM Signal (Envelope)');
xlabel('Time (s)');
ylabel('Amplitude');

%% 2. Frequency Modulation (FM)


% Modulation
kf = 100; % Frequency deviation constant
FM_signal = cos(2 * pi * fc * t + kf * cumsum(m)/fs);
% Demodulation
FM_demodulated = diff(unwrap(angle(FM_signal))) * (fs / (2 * pi * kf));

% Plot FM results
subplot(3, 1, 3);
plot(t(1:end-1), FM_demodulated, 'm');
title('Demodulated FM Signal');
xlabel('Time (s)');
ylabel('Amplitude');

figure;
plot(t, m, 'b', t(1:end-1), FM_demodulated, 'm');
title('FM Modulation and Demodulation Comparison');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Original Message Signal', 'FM Demodulated Signal');

%% 3. Phase Modulation (PM)


% Modulation
kp = pi/2; % Phase deviation constant
PM_signal = cos(2 * pi * fc * t + kp * m);

% Demodulation
PM_demodulated = diff(unwrap(angle(PM_signal))) * fs / (2 * pi * kp);

% Plot PM results
figure;
subplot(2, 1, 1);
plot(t, m, 'b', t, PM_signal, 'g');
title('PM Modulation and Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Message Signal', 'PM Signal');

subplot(2, 1, 2);
plot(t(1:end-1), PM_demodulated, 'c');
title('Demodulated PM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('PM Demodulated Signal');

Key Features of the Code:

AM Demodulation: Uses the Hilbert transform to extract the envelope of the AM


signal.
FM Demodulation: Uses phase unwrapping (unwrap) and differentiation to extract
the frequency information.
PM Demodulation: Similar to FM, but with proper scaling for the phase deviation
constant (kp).

Output:

Plots for each modulation type showing the message signal, modulated signal,
and the demodulated signal.
Comparison of the original message with the demodulated signals for FM and PM.

You might also like