Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

clc;

close;
clear;
fm=input('Enter thee input signal frequncy:');
k=input('Enter the number of cycles of input signal:');
A=input('Enter the amplitude of input signal:');
tm=0:1/(fm*fm):k/fm;
x=A*cos(2*%pi*fm*tm);
figure(1)
plot(tm,x);
title('ORIGINAL SIGNAL');
xlabel('Time');
ylabel('amplitude');
xgrid(1)
//under samplimg
fs1=1.5*fm;
n1=0:1/fs1:k/fm;
xn=A*cos(2*%pi*fm*n1);
figure(2)
subplot(3,1,1);
plot2d3(n1,xn);
plot(n1,xn,'r');
title('Under Sampling');
xlabel('Time');
ylabel('Amplitude');
legend('Sampled signal','Recondtructed signal');
xgrid(1)
//nyquist sampling
fs2=2*fm;
n2=0:1/fs2:k/fm;
xn=A*cos(2*%pi*fm*n2);
figure(2);
subplot(3,1,2);
plot2d3(n2,xn);
plot(n2,xn,'r');
title('Nyquist Sampling');
xlabel('Time');
ylabel('Amplitude');
legend('Sampling signal','Reconstructed signal');
xgrid(1)
//over sampling
fs3=2*fm;
n3=0:1/fs3:k/fm;
xn=A*cos(2*%pi*fm*n3);
figure(2);
subplot(3,1,3);
plot2d3(n3,xn);
plot(n3,xn,'r');
title('Nyquist Sampling');
xlabel('Time');
ylabel('Amplitude');
legend('Sampling signal','Reconstructed signal');
xgrid(1)

You might also like