Sampling Theorem


%to generate a sinusoidal signal and verify sampling theorem

tfinal= 0.02;
t=0:0.00005:tfinal;
fd=input('enter the analog frequency');
xt=sin(2*pi*fd*t);

%for undersampling plot
fs1=fd*1.3;
n1=0:1/fs1:tfinal;
xn=sin(2*pi*n1*fd);
subplot(3,1,1);
plot(t,xt,'b',n1,xn,'r*-');

xlabel('time');
ylabel('Amplitude');

title('undersampling plot');

%for Nyquist plot
fs2=2*fd;
n2=0:1/fs2:tfinal;
xn1=sin(2*pi*n2*fd);
subplot(3,1,2);
plot(t,xt,'b',n2,xn1,'r*-');

xlabel('time');
ylabel('Amplitude');

title('Nyquist Plot');

%for oversampling plot
fs3=5*fd;
n3=0:1/fs3:tfinal;
xn2=sin(2*pi*n3*fd);
subplot(3,1,3);
plot(t,xt,'b',n3,xn2,'r*-');
title('Oversampling Plot');
xlabel('time');
ylabel('amplitude');
legend('analog','discrete');

OUTPUT:

enter the analog frequency 500



Comments