Sampling
Sampling
f1 = 1000;
f2 = 1900;
fmax = max(f1,f2);
T = 1/min(f1,f2);
t = 0:0.01*T:5*T;
x = cos(2*pi*t*f1)+ cos(2*pi*t*f2);
subplot(2,2,1);
plot(t,x); grid on;
title('conntinuous signal');
xlabel('t');
ylabel('x(t)');
fs1 = 10*fmax;
n1 = 0:1/fs1:5*T;
x1 = cos(2*pi*f1*n1)+cos(2*pi*f2*n1);
subplot(2,2,2);
stem(n1,x1); hold on;
plot(n1,x1,'r'); grid on; hold off;
title('over sampling ');
xlabel('n'); ylabel('x(n)');
fs2 = 2*fmax;
n2 = 0:1/fs2:5*T;
x2 = cos(2*pi*f1*n2)+cos(2*pi*f2*n2);
subplot(2,2,3);
stem(n2,x2); hold on;
plot(n2,x2,'r'); grid on; hold off;
title('nyquist frequency');
xlabel('n'); ylabel('x(n)');
fs3 = 1.2*fmax;
n3 = 0:1/fs3:5*T;
x3 = cos(2*pi*f1*n3)+cos(2*pi*f2*n3);
subplot(2,2,4);
stem(n3,x3); hold on;
plot(n3,x3,'r'); grid on; hold off;
title('undersampling ');
xlabel('n'); ylabel('x(n)');