University School of Automation & Robotics

Personal resource archive for various courses.

9.m

% Pulse Position Modulation (PPM)
close all; clear; clc;

fc = 100;         % Carrier frequency
fs = 1000;        % Sampling frequency
f1 = 80;          % Message frequency

t = 0:1/fs:((2/f1)-(1/fs));
x1 = 0.4 * cos(2*pi*f1*t) + 0.5;

% Modulation
y1 = modulate(x1, fc, fs, 'ppm');

subplot(3,1,1);
plot(x1);
axis([0 15 0 1]);
title('Original Signal (f1 = 80Hz, fs = 1000Hz)');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(3,1,2);
plot(y1);
axis([0 250 -0.2 1.2]);
title('PPM Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');

% Demodulation
x1_recover = demod(y1, fc, fs, 'ppm');
subplot(3,1,3);
plot(x1_recover);
axis([0 15 0 1]);
title('Recovered Signal (Single Tone, f1 = 80Hz)');
xlabel('Time (s)');
ylabel('Amplitude');
sgtitle('Sujal Singh (04119051723)')