clc;clear;close all;
f=60;
T=0.1;
t=0:1e-4:T;
x=sin(2*pi*f*t);

fs1=200;
fs2=100;
n1=0:1/fs1:T-1/fs1;
x1=sin(2*pi*f*n1);
n2=0:1/fs2:T-1/fs2;
x2=sin(2*pi*f*n2);
figure;
subplot(3,1,1);
plot(t,x,'b','LineWidth',1.5);
xlabel('Time(s)');
ylabel('Amplitude');
title('original signal x(t)=sin(2pift),f=60hz');
grid on;
subplot(3,1,2);
stem(n1,x1,'r','filled','LineWidth',1.2);
xlabel('time(s)');
ylabel('amplitude');
title('discrete time signal sampled signal at fs=200hz(no aliasing)');
subplot(3,1,3);
stem(n2,x2,'m','filled','LineWidth',1.2);
xlabel('time(s)');
ylabel('amplitude');
title('discrete time signal sampled signal at fs=100hz(aliasing)');
grid on;
