%to study the sampling theorem and it's reconstruction
close all;
clear all;
clc
t=-10:.01:10;
T=4;
fm = 1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
title('Continuos Time Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid;
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('TIME');ylabel('x(n)');
title('Discrete Time Signal with fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1);
grid;
% Generate discrete time signals for fs = 2fm and fs = 8fm
n2 = -5:1:5;
x2 = cos(2*pi*fm*n2/fs2);
subplot(2,2,3);
stem(n2, x2);
xlabel('TIME'); ylabel('x(n)');
title('Discrete Time Signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2);
n3=-20:1:20;
x3 = cos(2*pi*fm*n3/fs3);
subplot(2,2,4);
stem(n3,x3);
xlabel('TIME'); ylabel('x(n)');
title('Discrete Time Signal with fs=8fm');
hold on;
subplot(2,2,4);
plot(n3,x3);
grid;
sgtitle('Sujal Singh (04119051723)') 
