Sampling Theorem
t=0:0.001:1;
f=input('enter input frequency');
x=sin(2*3.14*f*t);
subplot(4,2,1);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('input signal');
fs1=input('enter the sampling frequency<input signal frequency');
fs2=input('enter the sampling frequency=input signal frequency');
fs3=input('enter the sampling frequency>input signal frequency');
t1=0:1/fs1:1;
x1=sin(2*3.14*f*t1);
subplot(4,2,2);
stem(t1,x1);
xlabel('time');
ylabel('amplitude');
title('undersampling at fs<2f');
subplot(4,2,3);
plot(t1,x1);
xlabel('time');
ylabel('amplitude');
title('reconstructed undersampling fs<2f signal');
t2=0:1/fs2:1;
x2=sin(2*3.14*f*t2);
subplot(4,2,4);
stem(t2,x2);
xlabel('time');
ylabel('amplitude');
title('sampled at nyquist rate fs=2f');
subplot(4,2,5);
plot(t2,x2);
xlabel('time');
ylabel('amplitude');
title('reconstructed signal fs=2f signal');
t3=0:1/fs3:1;
x3=sin(2*3.14*f*t3);
subplot(4,2,6);
stem(t3,x3);
xlabel('time');
ylabel('amplitude');
title('oversampled fs>2f signal');
subplot(4,2,7);
plot(t3,x3);
xlabel('time');
ylabel('amplitude');
title('reconstructed oversampled fs>2f signal');
----------------OUTPUT-------------------
enter input frequency15
enter the sampling frequency<input signal frequency10
enter the sampling frequency=input signal frequency30
enter the sampling frequency>input signal frequency500