exp 3 sampling input output
exp 3 sampling input output
clc
clear all
close all
t=-100:01:100;
fm=0.02;
x=cos(2*pi*t*fm); subplot(2,2,1);
plot(t,x);
xlabel('time in sec');
ylabel('x(t)');
title('Continuous time signal');
fs1=0.01;
n=-5:0.4:5
x1=cos(2*pi*fm*n/fs1);
subplot(2,2,2);
plot(n,x1);
hold on
% subplot(2,2,2);
stem(n,x1,':');
title('Discrete time signal x(n) with fs<2fm');
xlabel('n');
ylabel('x(n)');
fs2=0.04;
n1=-5:0.2:5;
x2=cos(2*pi*fm*n1/fs2);
subplot(2,2,3);
plot(n1,x2);
hold on;
% subplot(2,2,3);
stem(n1,x2,':');
title('Discrete time signal x(n) with fs=2fm');
xlabel('n');
ylabel('x(n)');
n2=-40:40;
fs3=0.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(2,2,4);
plot(n2,x3);
hold on;
% subplot(2,2,4);
stem(n2,x3,':');
xlabel('n');
ylabel('x(n)');
title('Discrete time signal x(n) with fs>2fm');
Output:
0.5 0.5
x(n)
x(t)
0 0
-0.5 -0.5
-1 -1
-100 -50 0 50 100 -5 0 5
time in sec n
Discrete time signal x(n) with fs=2fm Discrete time signal x(n) with fs>2fm
1 1
0.5 0.5
x(n)
x(n)
0 0
-0.5 -0.5
-1 -1
-5 0 5 -40 -20 0 20 40
n n