Professional Documents
Culture Documents
clc;
clear all;
close all;
% for y2
r2 = y2 .* cs; % rectified signal
[num, den] = butter(2, fc*2/fs); % lowpass filter
z2 = filter(num, den, r2);
% for y3
r3 = y3 .* cs; % rectified signal
[num, den] = butter(2, fc*2/fs); % lowpass filter
z3 = filter(num, den, r3);
% we can also use inbuilt ammod and amdemmod functions for generating
% amplitude modulated and demodulated signals
figure;
subplot(4, 3, 1:3);
plot(t, ms);
xlabel("Time(s)");
ylabel("Amplitude");
title("Modulating Signal (fm = 200 Hz)");
subplot(4, 3, 4:6);
plot(t, cs);
xlabel("Time(s)");
ylabel("Amplitude");
title("Carrier Signal (fc = 3 kHz)");
subplot(4, 3, 7);
plot(t, y1);
xlabel("Time(s)");
ylabel("Amplitude");
title("Under Modulated Signal (m = 0.5)");
subplot(4, 3, 8);
plot(t, y2);
xlabel("Time(s)");
ylabel("Amplitude");
title("Perfectly Modulated Signal (m = 1)");
subplot(4, 3, 9);
plot(t, y3);
xlabel("Time(s)");
ylabel("Amplitude");
title("Over Modulated Signal (m = 2)");
subplot(4, 3, 10);
plot(t, z1);
xlabel("Time(s)");
ylabel("Amplitude");
title("De Modulated Signal (m = 0.5)");
subplot(4, 3, 11);
plot(t, z2);
xlabel("Time(s)");
ylabel("Amplitude");
title("De Modulated Signal (m = 1)");
subplot(4, 3, 12);
plot(t, z3);
xlabel("Time(s)");
ylabel("Amplitude");
title("De Modulated Signal (m = 2)");