//%To Study Sampling Theorem & Aliasing Effect
clc; //%to clear screen
clear all; //%removes all variables from the workspace,functions
//close all; //%closes all the open figure windows.
//% To generate analog DT signal
A=1;
T=4;
Fm=1/T;
t=-10:.01:10;
x=A*cos(2*%pi*Fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('Original Analog Signal');
//%sampling frequency fs<2Fm
fs=1.2*Fm;
n=-5:1:5; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs);//%T=1/fs
subplot(2,2,2);
plot2d3(n,xn);
//holdon; //holds the current plot.
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs<2Fm');
//%sampling frequency
fs=2*Fm;
n=-5:1:5; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs);//%T=1/fs
subplot(2,2,3);
plot2d3(n,xn);
//holdon;
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs=2Fm');
//%sampling frequency fs>2Fm
fs=8*Fm;
n=-20:1:20; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs);//%T=1/fs
subplot(2,2,4);
plot2d3(n,xn);
//holdon;
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs>2Fm');
//%To Study Sampling Theorem & Aliasing Effect
clc; //%to clear screen
clear all; //%removes all variables from the workspace,functions
//close all; //%closes all the open figure windows.
//% To generate analog DT signal
A=1;
Fm=0.02;
t=-100:.01:100;
x=A*cos(2*%pi*Fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('Original Analog Signal');
//%sampling frequency fs1<2Fm
fs1=0.02;
n=-5:1:5; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs1);//%T=1/fs1
subplot(2,2,2);
plot2d3(n,xn);
//holdon; //holds the current plot.
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs1<2Fm');
//%sampling frequency
fs2=0.04;
n=-10:1:10; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs2);//%T=1/fs2
subplot(2,2,3);
plot2d3(n,xn);
//holdon;
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs2=2Fm');
//%sampling frequency fs3>2Fm
fs3=0.08;
n=-20:1:20; //%t=nT
xn=A*cos(2*%pi*Fm*n*1/fs3);//%T=1/fs3
subplot(2,2,4);
plot2d3(n,xn);
//holdon;
plot(n,xn);
xlabel('time');
ylabel('amplitude');
title('DT signal for fs>2Fm');