All All
All All
clc;
clear all;
close all;
t=-10:.05:10;
T=6;fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.6*fm;
fs2=2*fm;
fs3=6*fm;
n1=-5:1:5;
xn1=cos(2*pi*n1*fm/fs1);
subplot(2,2,1),plot(t,x);
xlabel('Time in sec'),ylabel('x(t)')
title('continuous time signal')
subplot(2,2,2),stem(n1,xn1)
hold on
subplot(2,2,2),plot(n1,xn1)
xlabel('n'),ylabel('x(n)')
title('discrete time signal with fs<2fm')
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(2,2,3),stem(n2,xn2)
hold on
subplot(2,2,3),plot(n2,xn2)
xlabel('n'),ylabel('x(n)')
title('Discrete-time signal with fs=2fm')
n3=-15:1:15;
xn3=cos(2*pi*n3*fm/fs3);
subplot(2,2,4),stem(n3,xn3)
xlabel('n'),ylabel('x(n)')
title('Discrete-time signal with fs>2fm')
2.
Clc;
clear all;
close all;
xn=input('Enter the sequence');
N=input('Enter the number of points in dft');
L=length(xn)
if(N<L)
disp('N must be greater than or equal to L')
end
xk=fft(xn,N)
Op:
Enter the sequence[1 1 1 1 1 1 0 0]
Enter the number of points in dft8
L=
xk =
Columns 1 through 5
6.0000
Columns 6 through 8
3.
clear all
xk=input('enter the sequence');
xn=ifft(xk
xn =
4.
SAME PROGRAM
OP:
Enter the numerator coefficients[1 3]
Enter the denominator coefficients[1 3 2]
Enter the sampling time15
T=
15
Transfer function:
z^2 + 3 z + 2
------------z+3
Sampling time: 15
P=
-3
ans =
OP:
enter the order of the filter:49
N=
49
h=
Columns 1 through 11
-0.0000 -0.0140 0.0000 0.0154 -0.0000 -0.0170 0.0000 0.0190 -0.0000 -0.0215 0.0000
Columns 12 through 22
0.0248 -0.0000 -0.0293 0.0000 0.0358 -0.0000 -0.0461 0.0000 0.0645 -0.0000 -0.1075
Columns 23 through 33
0.0000 0.3226 0.5067 0.3226 0.0000 -0.1075 -0.0000 0.0645 0.0000 -0.0461 -0.0000
Columns 34 through 44
0.0358 0.0000 -0.0293 -0.0000 0.0248 0.0000 -0.0215 -0.0000 0.0190 0.0000 -0.0170
Columns 45 through 49
h=
Columns 1 through 11
-0.0000 -0.0011 0.0000 0.0025 -0.0000 -0.0041 0.0000 0.0061 -0.0000 -0.0086 0.0000
Columns 12 through 22
0.0119 -0.0000 -0.0164 0.0000 0.0229 -0.0000 -0.0332 0.0000 0.0516 -0.0000 -0.0946
Columns 23 through 33
0.0000 0.3097 0.5067 0.3097 0.0000 -0.0946 -0.0000 0.0516 0.0000 -0.0332 -0.0000
Columns 34 through 44
0.0229 0.0000 -0.0164 -0.0000 0.0119 0.0000 -0.0086 -0.0000 0.0061 0.0000 -0.0041
Columns 45 through 49
h=
Columns 1 through 11
-0.0000 -0.0002 0.0000 0.0009 -0.0000 -0.0023 0.0000 0.0043 -0.0000 -0.0073 0.0000
Columns 12 through 22
0.0115 -0.0000 -0.0172 0.0000 0.0252 -0.0000 -0.0372 0.0000 0.0576 -0.0000 -0.1024
Columns 23 through 33
0.0000 0.3171 0.5000 0.3171 0.0000 -0.1024 -0.0000 0.0576 0.0000 -0.0372 -0.0000
Columns 34 through 44
0.0252 0.0000 -0.0172 -0.0000 0.0115 0.0000 -0.0073 -0.0000 0.0043 0.0000 -0.0023
Columns 45 through 49
h=
Columns 1 through 11
-0.0000 -0.0012 0.0000 0.0017 -0.0000 -0.0029 0.0000 0.0049 -0.0000 -0.0077 0.0000
Columns 12 through 22
0.0118 -0.0000 -0.0174 0.0000 0.0254 -0.0000 -0.0373 0.0000 0.0577 -0.0000 -0.1025
Columns 23 through 33
0.0000 0.3174 0.5005 0.3174 0.0000 -0.1025 -0.0000 0.0577 0.0000 -0.0373 -0.0000
Columns 34 through 44
0.0254 0.0000 -0.0174 -0.0000 0.0118 0.0000 -0.0077 -0.0000 0.0049 0.0000 -0.0029
Columns 45 through 49
>>