You are on page 1of 4

VERIFICATION OF SAMPLING THEOREM

%TRYING SAMPLING THEOREM AT DIFFERENT SAMPLING FREQUENCIES FOR A GIVEN


%SIGNAL
%ADARSH BHARDWAJ
%USN 1MS16EE003
fy=input('Enter input signal frequency');
wy=2*pi*fy;
t1=0:0.01:5;
y1=sin(wy*t1);
subplot(3,3,1);
plot(t1,y1);
grid on;
xlabel('time');
ylabel('amplitude');
title('INPUT SIGNAL');
hold on;
subplot(3,3,2);
plot(t1,y1);
grid on;
xlabel('time');
ylabel('amplitude');
title('INPUT SIGNAL');
hold on;
subplot(3,3,3);
plot(t1,y1);
grid on;
xlabel('time');
ylabel('amplitude');
title('INPUT SIGNAL');
hold on;

fs1=1.2*fy;
t2=0:1/fs1:5;
y2=sin(wy*t2);
subplot(3,3,4);
stem(t2,y2);
hold on;
plot(t2,y2);
grid on;
xlabel('time');
ylabel('amplitude');
title('UNDER SAMPLED SIGNAL');
hold on;
y4f=fft(y2);
l2=0:length(y4f)-1;
subplot(3,3,7);
plot(l2,y4f);
hold on;
xlabel('freq');
ylabel('magnitude');
title('SPECTRUM OF UNDER SAMPLED SIGNAL');

fs2=2*fy;
t3=0:1/(fs2*fs2):5;
y3=sin(wy*t3);
subplot(3,3,5);
stem(t3,y3);
hold on;
plot(t3,y3);
grid on;
xlabel('time');
ylabel('amplitude');
title('RIGHTLY SAMPLED SIGNAL');
hold on;
y3f=fft(y3);
l3=0:length(y3f)-1;
subplot(3,3,8);
plot(l3,y3f);
hold on;
xlabel('freq');
ylabel('magnitude');
title('SPECTRUM OF RIGHTLY SAMPLED SIGNAL');

fs3=7*fy;
t4=0:1/(fs3*fs3):5;
y4=sin(wy*t4);
subplot(3,3,6);
stem(t4,y4);
hold on;
plot(t4,y4);
grid on;
xlabel('time');
ylabel('amplitude');
title('OVER SAMPLED SIGNAL');
hold on;
y4f=fft(y4);
l4=0:length(y4f)-1;
subplot(3,3,9);
plot(l4,y4f);
hold on;
xlabel('freq');
ylabel('magnitude');
title('SPECTRUM OF OVER SAMPLED SIGNAL');

INPUT:

Enter input signal frequency 1


OUTPUT:

%TRYING SAMPLING THEOREM ON MULTIPLE SIGNALS HAVING DIFFERENT FREQUENCIES


%ADARSH BHARDWAJ
%USN 1MS16EE003
f1=input('Enter the input signal frequency of first signal');
f2=input('Enter the input signal frequency of second signal');
t=0:0.01:5;
w1=2*pi*f1;
w2=2*pi*f2;
y1=sin(w1*t);
y2=sin(w2*t);
y3=y1+y2;
subplot(3,1,1);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('ORIGINAL INPUT SIGNAL');
hold on;
fs=20*max(f1,f2);
t1=0:1/fs:5;
y4=sin(2*pi*f1*t1)+sin(2*pi*f2*t1);
subplot(3,1,2);
stem(t1,y4);
xlabel('time');
ylabel('amplitude');
title('SAMPLED SIGNAL');
hold on;
y5=fft(y4);
subplot(3,1,3);
plot(t1,y5);
xlabel('FREQUENCY');
ylabel('MAGNITUDE');
title('SAMPLED SIGNAL IN FREQUENCY DOMAIN BY FFT');

INPUT:

Enter the input signal frequency of first signal 3


Enter the input signal frequency of second signal 5

OUTPUT:

You might also like