%program for dsbsc modulation and demodulation
close all;
clear all;
clc;

t = 0:0.000001:0.001;
Vm = 1;
Vc = 1;
fm = 2000;
fc = 50000;

m_t = Vm * sin(2 * pi * fm * t);
subplot(4,1,1);
plot(t, m_t);
title('Message Signal m_t');
xlabel('Time (s)');
ylabel('Amplitude');

c_t = Vc * sin(2 * pi * fc * t);
subplot(4,1,2);
plot(t, c_t);
title('Carrier Signal c_t');
xlabel('Time (s)');
ylabel('Amplitude');

subplot(4,1,3);
s_t = m_t .* c_t;
hold on;
plot(t, s_t);
plot(t,m_t,'r:');
plot(t,-m_t,'r:');
hold off;
title('DSB-SC Signal s_t');
xlabel('Time (s)');
ylabel('Amplitude');

r_t = s_t .* c_t;

[b, a] = butter(1, 0.01);
mr = filter(b, a, r_t);
subplot(4,1,4);
plot(t, mr);
title('Recovered Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
sgtitle('Sujal Singh (04119051723)')
