Discrete Time Signal Processing - Prof - Mr. Rajiv Suhas Tawde

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

Scilab Manual for

Discrete Time Signal Processing


by Prof Mr. Rajiv Suhas Tawde
Others
Mumbai University/padmabhushan
Vasantdada Patil Pratishthan’S College Of
Engineering ( Pvppcoe )1

Solutions provided by
Prof Mr. Rajiv Suhas Tawde
Others
Mumbai University/padmabhushan Vasantdada Patil Pratishthan’S College Of E

November 22, 2021

1 Funded by a grant from the National Mission on Education through ICT,


http://spoken-tutorial.org/NMEICT-Intro. This Scilab Manual and Scilab codes
written in it can be downloaded from the ”Migrated Labs” section at the website
http://scilab.in
1
Contents

List of Scilab Solutions 4

1 Linear Convolution Without Using Inbuilt Scilab Convolu-


tion Function 5

2 Derive The Four Point Twiddle Factor Matrix 7

3 Four Point Dit-Fft Without Using Inbuilt Scilab Fft Func-


tion 9

4 Four Point Idit-Fft Without Using Inbuilt Scilab Fft Func-


tion 11

5 Four Point Dif-Fft Without Using Inbuilt Scilab Fft Func-


tion 16

6 Four Point Idif-Fft Without Using Inbuilt Scilab Fft Func-


tion 18

7 Derive The Six Point Twiddle Factor Matrix [w6] Useful


For Dft Computation 23

8 Derive The Eight Point Twiddle Factor Matrix For Com-


puting Inverse Dft 26

9 Filtering Of Long Data Sequences 30

10 Implement Impulse Invariant Method 40

2
11 To Design Butterworth Filter With Minimum Readymade
Scilab Functions 43

12 To Design Chebyshev Filter With Minimum Readymade


Scilab Functions. 46

13 Designing Two Stage Decimator 50

14 Compute Dft Using Matrix Approach And Then Using Dft


Properties. 54

3
List of Experiments

Solution 1.0 Experiment Number 1 . . . . . . . . . . . . . . . 5


Solution 2.0 Experiment Number 2 . . . . . . . . . . . . . . . 7
Solution 3.0 Experiment Number 3 . . . . . . . . . . . . . . . 9
Solution 4.0 Experiment Number 4 . . . . . . . . . . . . . . . 11
Solution 4.1 Experiment Number 4 extra solution . . . . . . . 13
Solution 5.0 Experiment Number 5 . . . . . . . . . . . . . . . 16
Solution 6.0 Experiment Number 6 . . . . . . . . . . . . . . . 18
Solution 6.1 Experiment Number 6 extra solution . . . . . . . 20
Solution 7.0 Experiment Number 7 . . . . . . . . . . . . . . . 23
Solution 8.0 Experiment Number 8 . . . . . . . . . . . . . . . 26
Solution 9.0 Experiment Number 9 . . . . . . . . . . . . . . . 30
Solution 10.0 Experiment Number 10 . . . . . . . . . . . . . . . 40
Solution 11.0 Experiment Number 11 . . . . . . . . . . . . . . . 43
Solution 12.0 Experiment Number 12 . . . . . . . . . . . . . . . 46
Solution 13.0 Experiment Number 13 . . . . . . . . . . . . . . . 50
Solution 14.0 Experiment Number 14 . . . . . . . . . . . . . . . 54

4
Experiment: 1

Linear Convolution Without


Using Inbuilt Scilab
Convolution Function

Scilab code Solution 1.0 Experiment Number 1

1 //AIM : L i n e a r c o n v o l u t i o n w i t h o u t u s i n g i n b u i l t
Scilab convolution function .
2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 10
4 clc ;
5 clear ;
6 // Given t h a t x ( n ) = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } and h ( n ) ={1 ,2}
7 // S o l n :
8 x0 =1;
9 x1 =2;
10 x2 =3;
11 x3 =4;
12 x4 =5;
13 x5 =6;
14 x6 =7;
15 x7 =8;
16 h0 =1;

5
17 h1 =2;
18 xhn0_a = x0 * h0 ;
19 xhn1_a = x1 * h0 ;
20 xhn2_a = x2 * h0 ;
21 xhn3_a = x3 * h0 ;
22 xhn4_a = x4 * h0 ;
23 xhn5_a = x5 * h0 ;
24 xhn6_a = x6 * h0 ;
25 xhn7_a = x7 * h0 ;
26
27 xhn0_b = x0 * h1 ;
28 xhn1_b = x1 * h1 ;
29 xhn2_b = x2 * h1 ;
30 xhn3_b = x3 * h1 ;
31 xhn4_b = x4 * h1 ;
32 xhn5_b = x5 * h1 ;
33 xhn6_b = x6 * h1 ;
34 xhn7_b = x7 * h1 ;
35
36 y0 = xhn0_a ;
37 y1 = xhn0_b + xhn1_a ;
38 y2 = xhn1_b + xhn2_a ;
39 y3 = xhn2_b + xhn3_a ;
40 y4 = xhn3_b + xhn4_a ;
41 y5 = xhn4_b + xhn5_a ;
42 y6 = xhn5_b + xhn6_a ;
43 y7 = xhn6_b + xhn7_a ;
44 y8 = xhn7_b ;
45 disp ({ , y0 , y1 , y2 , y3 , y4 , y5 , y6 , y7 , y8 ,} , ’ Output o f
l i n e a r c o n v o l u t i o n i . e y ( n )= ’ )

6
Experiment: 2

Derive The Four Point Twiddle


Factor Matrix

Scilab code Solution 2.0 Experiment Number 2

1 //AIM : D e r i v e t h e 4 p o i n t t w i d d l e f a c t o r m a t r i x .
2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 10
4 clc ;
5 clear ;
6 W40 = cos (0) -( sqrt ( -1) * sin (0) ) ;
7 W41 = cos ( %pi /2) -( sqrt ( -1) ) *( sin ( %pi /2) ) ;
8 W42 = cos ( %pi ) -( sqrt ( -1) ) *( sin ( %pi ) ) ;
9 W43 = cos ((3* %pi ) /2) -( sqrt ( -1) ) * sin ((3* %pi ) /2) ;
10
11 disp ( W40 , ’W40= ’ )
12 disp ( W41 , ’W41= ’ )
13 disp ( W42 , ’W42= ’ )
14 disp ( W43 , ’W43= ’ )
15
16 W44 = W40 ;
17 W49 = W41 ;
18 W46 = W42 ;
19

7
20 W4_raw_matrix = [ W40 W40 W40 W40 ;
21 W40 W41 W42 W43 ;
22 W40 W42 W44 W46 ;
23 W40 W43 W46 W49 ]
24 disp ( W4_raw_matrix , ’ W4 raw matrix= ’ )
25 disp ( ’ Type r e s u m e i n c o n s o l e and p r e s s e n t e r ’ )
26 pause
27 a = ceil ( - 1.225 D -16) ;
28 disp (a , ’ I m a g i n a r y p a r t o f W42 & I m a g i n a r y p a r t o f
W46 i . e . c e i l (− 1 . 2 2 5D−16)= ’ )
29 b = ceil ( - 1.837 D -16) ;
30 disp (b , ’ R e a l p a r t o f W43 i . e . c e i l (− 1 . 8 3 7D−16)= ’ )
31 c = int (6.123 D -17) ;
32 disp (c , ’ R e a l p a r t o f W41 & R e a l p a r t o f W49 i . e . i n t
( 6 . 1 2 3 D−17)= ’ )
33
34 // So W4 can be m o d i f i e d a s f o l l o w s :
35 d = real ( W42 ) ; // I m a g i n a r y p a r t i s i g n o r e d since it is
zero
36 e = imag ( W43 ) * sqrt ( -1) ; // R e a l p a r t i s i g n o r e d s i n c e i t
i s zero
37 f = imag ( W41 ) *( sqrt ( -1) ) ; // R e a l p a r t i s i g n o r e d s i n c e
i t i s zero
38
39 W4 =[ W40 W40 W40 W40 ;
40 W40 f d e ;
41 W40 d W44 d ;
42 W40 e d f ]
43 disp ( W4 , ’ F i n a l W4 m a t r i x = ’ )

8
Experiment: 3

Four Point Dit-Fft Without


Using Inbuilt Scilab Fft
Function

Scilab code Solution 3.0 Experiment Number 3

1 //AIM : Four p o i n t DIT−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2
3 // Computing f o u r p o i n t DFT f o r x ( n ) = { 1 , 2 , 3 , 4 } u s i n g
D e c i m a t i o n i n Time−F a s t
4 // F o u r i e r t r a n s f o r m ( i . e . DIT−FFT )
5 // w i t h o u t u s i n g readymade i n b u i l t S c i l a b f u n c t i o n s
f o r DFT/FFT .
6
7 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
8 //OS windows 10
9 clc ;
10 clear ;
11 // L e t u s b e g i n w i t h t h e programming . For
understanding , l e t us w r i t e the g i v e n
12 // d a t a a s
13 // x ( 0 ) =1; x ( 1 ) =2 , x ( 2 ) =3 , x ( 3 ) =4

9
14 x0 =1;
15 x2 =3;
16 x1 =2;
17 x3 =4;
18 // S t a g e I c o m p u t a t i o n
19 x0a = x2 + x0 ; // Computing S t a g e −I o u t p u t a t p o s i t i o n 1
20 disp ( x0a , ’ S t a g e −I o u t p u t a t p o s i t i o n 1 ’ )
21 x2b =( x2 - x0 ) *( -1) ; // Computing S t a g e −I o u t p u t a t
position 2
22 disp ( x2b , ’ S t a g e −I o u t p u t a t p o s i t i o n 2 ’ )
23 x1c = x3 + x1 ; // Computing S t a g e −I o u t p u t a t p o s i t i o n 3
24 disp ( x1c , ’ S t a g e −I o u t p u t a t p o s i t i o n 3 ’ )
25 x3d =( x3 - x1 ) *( -1) ; // Computing S t a g e −I o u t p u t a t
position 4
26 disp ( x3d , ’ S t a g e −I o u t p u t a t p o s i t i o n 4 ’ )
27 // S t a g e − I I c o m p u t a t i o n
28 x3d1 = x3d *( - sqrt ( -1) ) ; // M u l t i p l y by (− j ) i n t h e l a s t
line
29 disp ( x3d1 , ’ S t a g e − I I i n p u t a t t h e f o u r t h l i n e ’ )
30 X0 = x1c + x0a ; // Computing f i n a l s t a g e o u t p u t v a l u e X( 0 )
31 disp ( X0 , ’ The f i n a l s t a g e o u t p u t X( 0 )= ’ )
32 X1 = x3d1 + x2b ; // Computing f i n a l s t a g e o u t p u t v a l u e X
(1)
33 disp ( X1 , ’ The f i n a l s t a g e o u t p u t X( 1 )= ’ )
34 X2 =( x1c - x0a ) *( -1) ; // Computing f i n a l s t a g e o u t p u t
v a l u e X( 2 )
35 disp ( X2 , ’ The f i n a l s t a g e o u t p u t X( 2 )= ’ )
36 X3 =( x3d1 - x2b ) *( -1) ; // Computing f i n a l s t a g e o u t p u t
v a l u e X( 3 )
37 disp ( X3 , ’ The f i n a l s t a g e o u t p u t X( 3 )= ’ )
38 disp ({ , X0 , X1 , X2 , X3 ,} , ’ So , t h e DFT o f x ( n ) u s i n g
D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m ( DIT−FFT
) i s X( k )= ’ )

10
Experiment: 4

Four Point Idit-Fft Without


Using Inbuilt Scilab Fft
Function

Scilab code Solution 4.0 Experiment Number 4

1 //AIM : Four p o i n t IDIT−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2
3 // Computing f o u r p o i n t IDFT f o r X( k ) ={10,−2+2 j
,−2,−2−2 j } u s i n g
4 // I n v e r s e D e c i m a t i o n i n Time−F a s t F o u r i e r t r a n s f o r m
( i . e . IDIT−FFT )
5 // w i t h o u t u s i n g readymade i n b u i l t S c i l a b f u n c t i o n s
f o r IDFT/IFFT .
6
7 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
8 //OS windows 10
9 clc ;
10 clear ;
11 // L e t u s b e g i n w i t h t h e programming . For
understanding , l e t us w r i t e the g i v e n
12 // d a t a a s

11
13 //X( 0 ) =10;X( 1 ) =−2+2j , X( 2 ) =−2,X( 3 ) =−2−2 j
14 X0c =10; // X0c means c o m p l e x c o n j u g a t e o f XO
15 X2c = -2; // X2c means c o m p l e x c o n j u g a t e o f X2
16 X1c =( -2) +(( -1) *(2) *( sqrt ( -1) ) ) ; // X1c means c o m p l e x
c o n j u g a t e o f X1
17 X3c =( -2) -(( -1) *(2) *( sqrt ( -1) ) ) ; // X3c means c o m p l e x
c o n j u g a t e o f X3
18 disp ( X0c , ’X∗ ( 0 )= ’ )
19 disp ( X2c , ’X∗ ( 2 )= ’ )
20 disp ( X1c , ’X∗ ( 1 )= ’ )
21 disp ( X3c , ’X∗ ( 3 )= ’ )
22 x0_star =((( X3c + X1c ) *(1) ) +(( X2c + X0c ) *(1) ) ) *(1/4)
23 disp ( x0_star , ’ x ∗ ( 0 )= ’ )
24 x1_star =((( X3c - X1c ) *( -1) *( - sqrt ( -1) ) ) +( X2c - X0c ) *( -1)
) *(1/4) ;
25 disp ( x1_star , ’ x ∗ ( 1 )= ’ )
26 x2_star =((( X3c + X1c ) *(1) -( X2c + X0c ) ) *( -1) ) *(1/4) ;
27 disp ( x2_star , ’ x ∗ ( 2 )= ’ )
28 x3_star =(((( X3c - X1c ) *( -1) *( - sqrt ( -1) ) ) -(( X2c - X0c )
*( -1) ) ) *( -1) ) *(1/4) ;
29 disp ( x3_star , ’ x ∗ ( 3 )= ’ )
30 disp ({ , x0_star , x1_star , x2_star , x3_star ,} , ’ x ∗ ( n )= ’ )
31 // The computed v a l u e i s x ∗ ( n ) . But we n e e d x ( n ) a s
f i n a l output .
32 //We w i l l s e p a r a t e r e a l p a r t o f x ∗ ( n )
33 //We w i l l s e p a r a t e i m a g i n a r y p a r t o f x ∗ ( n ) and t a k e
i t s c o m p l e x c o n j u g a t e by
34 // m u l t i p l y i n g by a f a c t o r o f ( −1)
35 x0_star_real = real ( x0_star ) ;
36 x0_star_conj =( -1) *( imag ( x0_star ) ) ;
37 x1_star_real = real ( x1_star ) ;
38 x1_star_conj =( -1) *( imag ( x1_star ) ) ;
39 x2_star_real = real ( x2_star ) ;
40 x2_star_conj =( -1) *( imag ( x2_star ) ) ;
41 x3_star_real = real ( x3_star ) ;
42 x3_star_conj =( -1) *( imag ( x3_star ) ) ;
43 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x

12
44 // c o n j u g a t e i s t a k e n t o g e t x ( 0 ) , ( 1 ) , x ( 2 ) and x ( 3 )
45 x0 = x0_star_real + x0_star_conj
46 x1 = x1_star_real + x1_star_conj
47 x2 = x2_star_real + x2_star_conj
48 x3 = x3_star_real + x3_star_conj
49 disp ({ , x0 , x1 , x2 , x3 ,} , ’ So , t h e IDFT o f X( k ) u s i n g
I n v e r s e D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m
( IDIT−FFT) i s x ( n )= ’ )

Scilab code Solution 4.1 Experiment Number 4 extra solution

1 //AIM : Four p o i n t IDIT−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2 // ( T h i s i s an e x t r a s o l u t i o n )
3
4 // Computing f o u r p o i n t IDFT f o r X( k ) ={10,−2+2 j
,−2,−2−2 j } u s i n g
5 // I n v e r s e D e c i m a t i o n i n Time−F a s t F o u r i e r t r a n s f o r m
( i . e . IDIT−FFT )
6 // w i t h o u t u s i n g readymade i n b u i l t S c i l a b f u n c t i o n s
f o r IDFT/IFFT .
7
8 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
9 //OS windows 10
10 clc ;
11 clear ;
12 // L e t u s b e g i n w i t h t h e programming . For
understanding , l e t us w r i t e the g i v e n
13 // d a t a a s
14 //X( 0 ) =10;X( 1 ) =−2+2j , X( 2 ) =−2,X( 3 ) =−2−2 j
15 X0_conj =10; // X 0 c o n j means c o m p l e x c o n j u g a t e o f XO
16 X2_conj = -2; // X 2 c o n j means c o m p l e x c o n j u g a t e o f X2
17 X1_conj =( -2) +(( -1) *(2) *( sqrt ( -1) ) ) ; // X 1 c o n j means
c o m p l e x c o n j u g a t e o f X1
18 X3_conj =( -2) -(( -1) *(2) *( sqrt ( -1) ) ) ; // X 3 c o n j means

13
c o m p l e x c o n j u g a t e o f X3
19 disp ( X0_conj , ’X∗ ( 0 )= ’ )
20 disp ( X2_conj , ’X∗ ( 2 )= ’ )
21 disp ( X1_conj , ’X∗ ( 1 )= ’ )
22 disp ( X3_conj , ’X∗ ( 3 )= ’ )
23 // S t a g e I c o m p u t a t i o n
24 X0a = X2_conj + X0_conj ; // Computing S t a g e −I o u t p u t a t
line 1
25 disp ( X0a , ’ S t a g e −I o u t p u t a t l i n e 1 ’ )
26 X2b =( X2_conj - X0_conj ) *( -1) ; // Computing S t a g e −I
output at l i n e 2
27 disp ( X2b , ’ S t a g e −I o u t p u t a t l i n e 2 ’ )
28 X1c = X3_conj + X1_conj ; // Computing S t a g e −I o u t p u t a t
line 3
29 disp ( X1c , ’ S t a g e −I o u t p u t a t l i n e 3 ’ )
30 X3d =( X3_conj - X1_conj ) *( -1) ; // Computing S t a g e −I
output at l i n e 4
31 disp ( X3d , ’ S t a g e −I o u t p u t a t l i n e 4 ’ )
32 // S t a g e I I c o m p u t a t i o n
33 X3d1 = X3d *( - sqrt ( -1) ) ; // M u l t i p l y by (− j ) i n t h e l a s t
line
34 disp ( X3d1 , ’ S t a g e − I I i n p u t a t t h e f o u r t h l i n e ’ )
35 x0_star = X1c + X0a ; // Computing s t a g e − I I o u t p u t v a l u e a t
line 1
36 disp ( x0_star , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 1= ’ )
37 x1_star = X3d1 + X2b ; // Computing s t a g e − I I o u t p u t v a l u e
at l i n e 2
38 disp ( x1_star , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 2 = ’
)
39 x2_star =( X1c - X0a ) *( -1) ; // Computing s t a g e − I I o u t p u t
value at l i n e 3
40 disp ( x2_star , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 3= ’ )
41 x3_star =( X3d1 - X2b ) *( -1) ; // Computing s t a g e − I I o u t p u t
value at l i n e 4
42 disp ( x3_star , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 4= ’ )
43 //Now we w i l l m u l t i p l y s t a g e − I I o u t p u t v a l u e s
i n d i v i d u a l l y with a f a c t o r o f
44 // ( 1 /N) . Here N=4 , So we w i l l m u l t i p l y by ( 1 / 4 )

14
45 x0_star_on_multiplication =(1/4) *( x0_star ) ; // M u l t i p l y
by ( 1 / 4 )
46 disp ( x0_star_on_multiplication , ’ x ∗ ( 0 )= ’ )
47 x1_star_on_multiplication =(1/4) *( x1_star ) ; // M u l t i p l y
by ( 1 / 4 )
48 disp ( x1_star_on_multiplication , ’ x ∗ ( 1 )= ’ )
49 x2_star_on_multiplication =(1/4) *( x2_star ) ; // M u l t i p l y
by ( 1 / 4 )
50 disp ( x2_star_on_multiplication , ’ x ∗ ( 2 )= ’ )
51 x3_star_on_multiplication =(1/4) *( x3_star ) ; // M u l t i p l y
by ( 1 / 4 )
52 disp ( x3_star_on_multiplication , ’ x ∗ ( 3 )= ’ )
53 disp ({ , x0_star_on_multiplication ,
x1_star_on_multiplication ,
x2_star_on_multiplication ,
x3_star_on_multiplication ,} , ’ x ∗ ( n )= ’ )
54 x0_star_real = real ( x0_star_on_multiplication ) ;
55 x0_star_conj =( -1) *( imag ( x0_star_on_multiplication ) ) ;
56 x1_star_real = real ( x1_star_on_multiplication ) ;
57 x1_star_conj =( -1) *( imag ( x1_star_on_multiplication ) ) ;
58 x2_star_real = real ( x2_star_on_multiplication ) ;
59 x2_star_conj =( -1) *( imag ( x2_star_on_multiplication ) ) ;
60 x3_star_real = real ( x3_star_on_multiplication ) ;
61 x3_star_conj =( -1) *( imag ( x3_star_on_multiplication ) ) ;
62 x0 = x0_star_real + x0_star_conj
63 x1 = x1_star_real + x1_star_conj
64 x2 = x2_star_real + x2_star_conj
65 x3 = x3_star_real + x3_star_conj
66 disp ({ , x0 , x1 , x2 , x3 ,} , ’ So , t h e IDFT o f X( k ) u s i n g
I n v e r s e D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m
( IDIT−FFT) i s x ( n )= ’ )

15
Experiment: 5

Four Point Dif-Fft Without


Using Inbuilt Scilab Fft
Function

Scilab code Solution 5.0 Experiment Number 5

1 //AIM : Four p o i n t DIF−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2
3 // Computing f o u r p o i n t DFT f o r x ( n ) = { 1 , 2 , 3 , 4 } u s i n g
4 // D e c i m a t i o n i n F r e q u e n c y −F a s t F o u r i e r t r a n s f o r m ( i .
e . DIF−FFT ) w i t h o u t u s i n g
5 // readymade i n b u i l t S c i l a b f u n c t i o n s f o r DFT/FFT .
6
7 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
8 //OS windows 10
9 clc ;
10 clear ;
11 x0 =1;
12 x1 =2;
13 x2 =3;
14 x3 =4;
15 // S t a g e I c o m p u t a t i o n

16
16 x0a = x2 + x0 ; // Computing S t a g e −I o u t p u t a t p o s i t i o n 1
17 disp ( x0a , ’ S t a g e −I o u t p u t a t p o s i t i o n 1 ’ )
18 x1b =( x3 + x1 ) ; // Computing S t a g e −I o u t p u t a t p o s i t i o n 2
19 disp ( x1b , ’ S t a g e −I o u t p u t a t p o s i t i o n 2 ’ )
20 x2c =( x2 - x0 ) *( -1) ; // Computing S t a g e −I o u t p u t a t
position 3
21 disp ( x2c , ’ S t a g e −I o u t p u t a t p o s i t i o n 3 ’ )
22 x3d =( x3 - x1 ) *( -1) ; // Computing S t a g e −I o u t p u t a t
position 4
23 disp ( x3d , ’ S t a g e −I o u t p u t a t p o s i t i o n 4 ’ )
24 // S t a g e − I I c o m p u t a t i o n
25 x3d1 = x3d *( - sqrt ( -1) ) ; // M u l t i p l y by (− j ) i n t h e l a s t
line
26 disp ( x3d1 , ’ S t a g e − I I i n p u t a t t h e f o u r t h l i n e ’ )
27 X0 = x1b + x0a ; // Computing f i n a l s t a g e o u t p u t v a l u e X( 0 )
28 disp ( X0 , ’ The f i n a l s t a g e o u t p u t X( 0 )= ’ )
29 X2 =( x1b - x0a ) *( -1) ; // Computing f i n a l s t a g e o u t p u t
v a l u e X( 1 )
30 disp ( X2 , ’ The f i n a l s t a g e o u t p u t X( 2 )= ’ )
31 X1 =( x3d1 + x2c ) ; // Computing f i n a l s t a g e o u t p u t v a l u e X
(2)
32 disp ( X1 , ’ The f i n a l s t a g e o u t p u t X( 1 )= ’ )
33 X3 =( x3d1 - x2c ) *( -1) ; // Computing f i n a l s t a g e o u t p u t
v a l u e X( 3 )
34 disp ( X3 , ’ The f i n a l s t a g e o u t p u t X( 3 )= ’ )
35 disp ({ , X0 , X1 , X2 , X3 ,} , ’ So , t h e DFT o f x ( n ) u s i n g
D e c i m a t i o n −i n −F r e q u e n c y F a s t F o u r i e r T r a n s f o r m (
DIF−FFT) i s X( k )= ’ )

17
Experiment: 6

Four Point Idif-Fft Without


Using Inbuilt Scilab Fft
Function

Scilab code Solution 6.0 Experiment Number 6

1 //AIM : Four p o i n t IDIF−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2
3 // Computing f o u r p o i n t IDFT f o r X( k ) ={10,−2+2 j
,−2,−2−2 j } u s i n g
4 // I n v e r s e D e c i m a t i o n i n F r e q u e n c y −F a s t F o u r i e r
t r a n s f o r m ( i . e . IDIF−FFT )
5 // w i t h o u t u s i n g readymade i n b u i l t S c i l a b f u n c t i o n s
f o r IDFT/IFFT .
6
7 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
8 //OS windows 10
9 clc ;
10 clear ;
11 // L e t u s b e g i n w i t h t h e programming . For
understanding , l e t us w r i t e the g i v e n
12 // d a t a a s

18
13 //X( 0 ) =10;X( 1 ) =−2+2j , X( 2 ) =−2,X( 3 ) =−2−2 j
14 X0c =10; // X0c means c o m p l e x c o n j u g a t e o f XO
15 X1c =( -2) +(( -1) *(2) *( sqrt ( -1) ) ) ; // X1c means c o m p l e x
c o n j u g a t e o f X1
16 X2c = -2; // X2c means c o m p l e x c o n j u g a t e o f X2
17 X3c =( -2) -(( -1) *(2) *( sqrt ( -1) ) ) ; // X3c means c o m p l e x
c o n j u g a t e o f X3
18 disp ( X0c , ’X∗ ( 0 )= ’ )
19 disp ( X1c , ’X∗ ( 1 )= ’ )
20 disp ( X2c , ’X∗ ( 2 )= ’ )
21 disp ( X3c , ’X∗ ( 3 )= ’ )
22 x0_star =(( X3c + X1c ) *(1) +( X2c + X0c ) *(1) ) *(1/4) ; //
Computing x ∗ ( 0 )
23 disp ( x0_star , ’ x ∗ ( 0 )= ’ )
24 x2_star =(((( X3c + X1c ) *(1) ) -(( X2c + X0c ) *(1) ) ) *( -1) )
*(1/4) ; // Computing x ∗ ( 2 )
25 disp ( x2_star , ’ x ∗ ( 2 )= ’ )
26 x1_star =(( X3c - X1c ) *( -1) *( - sqrt ( -1) ) +( X2c - X0c ) *( -1) )
*(1/4) ; // Computing x ∗ ( 1 )
27 disp ( x1_star , ’ x ∗ ( 1 )= ’ )
28 // Computing x ∗ ( 3 )
29 x3_star =(((( X3c - X1c ) *( -1) *( - sqrt ( -1) ) -( X2c - X0c ) *( -1)
) ) *( -1) ) *(1/4) ;
30 disp ( x3_star , ’ x ∗ ( 3 )= ’ )
31 disp ({ , x0_star , x1_star , x2_star , x3_star ,} , ’ x ∗ ( n )= ’ )
32 // The computed v a l u e i s x ∗ ( n ) . But we n e e d x ( n ) a s
f i n a l output .
33 //We w i l l s e p a r a t e r e a l p a r t o f x ∗ ( n )
34 //We w i l l s e p a r a t e i m a g i n a r y p a r t o f x ∗ ( n ) and t a k e
i t s c o m p l e x c o n j u g a t e by
35 // m u l t i p l y i n g by a f a c t o r o f ( −1)
36 x0_star_real = real ( x0_star ) ;
37 x0_star_conj =( -1) *( imag ( x0_star ) ) ;
38 x1_star_real = real ( x1_star ) ;
39 x1_star_conj =( -1) *( imag ( x1_star ) ) ;
40 x2_star_real = real ( x2_star ) ;
41 x2_star_conj =( -1) *( imag ( x2_star ) ) ;
42 x3_star_real = real ( x3_star ) ;

19
43 x3_star_conj =( -1) *( imag ( x3_star ) ) ;
44 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x
45 // c o n j u g a t e i s t a k e n t o g e t xx ( 0 ) , ( 1 ) , x ( 2 ) and x ( 3 )
46 x0 = x0_star_real + x0_star_conj ; // Computing x ( 0 )
47 x1 = x1_star_real + x1_star_conj ; // Computing x ( 1 )
48 x2 = x2_star_real + x2_star_conj ; // Computing x ( 2 )
49 x3 = x3_star_real + x3_star_conj ; // Computing x ( 3 )
50 disp ({ , x0 , x1 , x2 , x3 ,} , ’ So , t h e IDFT o f X( k ) u s i n g
I n v e r s e D e c i m a t i o n −i n −F r e q u e n c y F a s t F o u r i e r
T r a n s f o r m ( IDIF−FFT) i s x ( n )= ’ )

Scilab code Solution 6.1 Experiment Number 6 extra solution

1 //AIM : Four p o i n t IDIF−FFT w i t h o u t u s i n g i n b u i l t


S c i l a b FFT f u n c t i o n
2 // ( T h i s i s an e x t r a s o l u t i o n )
3
4 // Computing f o u r p o i n t IDFT f o r X( k ) ={10,−2+2 j
,−2,−2−2 j } u s i n g I n v e r s e
5 // D e c i m a t i o n i n F r e q u e n c y −F a s t F o u r i e r t r a n s f o r m ( i .
e . IDIF−FFT )
6 // w i t h o u t u s i n g readymade i n b u i l t S c i l a b f u n c t i o n s
f o r IDFT/IFFT .
7
8 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
9 //OS windows 10
10 clc ;
11 clear ;
12 // L e t u s b e g i n w i t h t h e programming . For
understanding , l e t us w r i t e the g i v e n
13 // d a t a a s
14 //X( 0 ) =10;X( 1 ) =−2+2j , X( 2 ) =−2,X( 3 ) =−2−2 j
15 X0_conj =10; // X 0 c o n j means c o m p l e x c o n j u g a t e o f X(O)
16 X1_conj =( -2) +(( -1) *(2) *( sqrt ( -1) ) ) ; // X 1 c o n j means

20
c o m p l e x c o n j u g a t e o f X( 1 )
17 X2_conj = -2; // X 2 c o n j means c o m p l e x c o n j u g a t e o f X( 2 )
18 X3_conj =( -2) -(( -1) *(2) *( sqrt ( -1) ) ) ; // X 3 c o n j means
c o m p l e x c o n j u g a t e o f X( 3 )
19 disp ( X0_conj , ’X∗ ( 0 )= ’ )
20 disp ( X1_conj , ’X∗ ( 1 )= ’ )
21 disp ( X2_conj , ’X∗ ( 2 )= ’ )
22 disp ( X3_conj , ’X∗ ( 3 )= ’ )
23 // S t a g e I c o m p u t a t i o n
24 X0a = X2_conj + X0_conj ; // Computing S t a g e −I o u t p u t a t
line 1
25 disp ( X0a , ’ S t a g e −I o u t p u t a t l i n e 1 ’ )
26 X1b =( X3_conj + X1_conj ) ; // Computing S t a g e −I o u t p u t a t
line 2
27 disp ( X1b , ’ S t a g e −I o u t p u t a t l i n e 2 ’ )
28 X2c =( X2_conj - X0_conj ) *( -1) ; // Computing S t a g e −I
output at l i n e 3
29 disp ( X2c , ’ S t a g e −I o u t p u t a t l i n e 3 ’ )
30 X3d =( X3_conj - X1_conj ) *( -1) ; // Computing S t a g e −I
output at l i n e 4
31 disp ( X3d , ’ S t a g e −I o u t p u t a t l i n e 4 ’ )
32 // S t a g e I I c o m p u t a t i o n
33 X3d1 = X3d *( - sqrt ( -1) ) ; // M u l t i p l y by (− j ) i n t h e l a s t
line
34 disp ( X3d1 , ’ S t a g e − I I i n p u t a t t h e f o u r t h l i n e ’ )
35 x0_conj = X1b + X0a ; // Computing s t a g e − I I o u t p u t v a l u e a t
line 1
36 disp ( x0_conj , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 1= ’ )
37 x2_conj =( X1b - X0a ) *( -1) ; // Computing s t a g e − I I o u t p u t
value at l i n e 2
38 disp ( x2_conj , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 2= ’ )
39 x1_conj = X3d1 + X2c ; // Computing s t a g e − I I o u t p u t v a l u e
at l i n e 3
40 disp ( x1_conj , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 3= ’ )
41 x3_conj =( X3d1 - X2c ) *( -1) ; // Computing s t a g e − I I o u t p u t
value at l i n e 4
42 disp ( x3_conj , ’ The s t a g e − I I o u t p u t v a l u e a t l i n e 4= ’ )
43 //Now we w i l l m u l t i p l y s t a g e − I I o u t p u t v a l u e s

21
i n d i v i d u a l l y with a f a c t o r o f
44 // ( 1 /N) . Here N=4 , So we w i l l m u l t i p l y by ( 1 / 4 )
45 x0_conj_final =(1/4) *( x0_conj )
46 disp ( x0_conj_final , ’ x ∗ ( 0 )= ’ )
47 x2_conj_final =(1/4) *( x2_conj )
48 disp ( x2_conj_final , ’ x ∗ ( 2 )= ’ )
49 x1_conj_final =(1/4) *( x1_conj )
50 disp ( x1_conj_final , ’ x ∗ ( 1 )= ’ )
51 x3_conj_final =(1/4) *( x3_conj )
52 disp ( x3_conj_final , ’ x ∗ ( 3 )= ’ )
53 disp ({ , x0_conj_final , x1_conj_final , x2_conj_final ,
x3_conj_final ,} , ’ So , t h e IDFT o f X( k ) u s i n g
I n v e r s e D e c i m a t i o n −i n −F r e q u e n c y F a s t F o u r i e r
T r a n s f o r m ( IDIF−FFT) i s x ( n )= ’ )

22
Experiment: 7

Derive The Six Point Twiddle


Factor Matrix [w6] Useful For
Dft Computation

Scilab code Solution 7.0 Experiment Number 7

1 //AIM : D e r i v e t h e s i x p o i n t t w i d d l e f a c t o r m a t r i x [W6
] u s e f u l f o r DFT c o m p u t a t i o n
2 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
3 //OS windows 10
4 clc ;
5 clear ;
6 // Computing t h e t w i d d l e f a c t o r v a l u e s f o r W60 , W61 ,
W62 , W63 , W64 , W65 :
7 W60 = int ( cos (0) ) -( sqrt ( -1) * int ( sin (0) ) ) ;
8 W61 = cos ((2* %pi *1) /6) -( sqrt ( -1) ) * sin ((2* %pi *1) /6) ;
9 W62 =( cos ((2* %pi *2) /6) ) -( sqrt ( -1) ) * sin ((2* %pi *2) /6) ;
10 W63 = cos ((2* %pi *3) /6) - int (( sqrt ( -1) ) * sin ((2* %pi *3) /6)
);
11 W64 = cos ((2* %pi *4) /6) -( sqrt ( -1) ) *( sin ((2* %pi *4) /6) ) ;
12 W65 = cos ((2* %pi *5) /6) -( sqrt ( -1) ) * sin ((2* %pi *5) /6) ;
13
14 disp ( W60 , ’W60= ’ )

23
15 disp ( W61 , ’W61= ’ )
16 disp ( W62 , ’W62= ’ )
17 disp ( W63 , ’W63= ’ )
18 disp ( W64 , ’W64= ’ )
19 disp ( W65 , ’W65= ’ )
20
21 //W60=W612=W618=W624=W630=W636 ; / / C y c l i c p r o p e r t y o f
twiddle factor
22 W66 = W60 ;
23 W612 = W66 ;
24 W618 = W612 ;
25 W624 = W618 ;
26 W630 = W624 ;
27 W636 = W630 ;
28
29 //W61=W67=W613=W619=W625 // C y c l i c p r o p e r t y o f
twiddle factor
30 W67 = W61 ;
31 W613 = W67 ;
32 W619 = W613 ;
33 W625 = W619 ;
34
35 //W62=W68=W614=W620 // C y c l i c p r o p e r t y o f t w i d d l e
factor
36 W68 = W62 ;
37 W614 = W68 ;
38 W620 = W614 ;
39
40 //W63=W69=W615=W621 // C y c l i c p r o p e r t y o f t w i d d l e
factor
41 W69 = W63 ;
42 W615 = W69 ;
43 W621 = W615 ;
44
45 //W64=W610=W616=W622 // C y c l i c p r o p e r t y o f t w i d d l e
factor
46 W610 = W64 ;
47 W616 = W610 ;

24
48 W622 = W616 ;
49
50 //W65=W613=W621=W629 // C y c l i c p r o p e r t y o f t w i d d l e
factor
51 W613 = W65 ;
52 W621 = W613 ;
53 W629 = W621 ;
54
55 W6 = [ W60 W60 W60 W60 W60 W60 ; W60 W61 W62 W63 W64 W65
; W60 W62 W64 W66 W68 W610 ; W60 W63 W66 W69 W612
W615 ; W60 W64 W68 W612 W616 W620 ; W60 W65 W610 W615
W620 W625 ];
56 // D i s p l a y i n g t h e W6 m a t r i x :
57 disp ( W6 , ’ [W6]= ’ )

25
Experiment: 8

Derive The Eight Point


Twiddle Factor Matrix For
Computing Inverse Dft

Scilab code Solution 8.0 Experiment Number 8

1 //AIM : D e r i v e t h e 8 p o i n t t w i d d l e f a c t o r m a t r i x f o r
c o m p u t i n g i n v e r s e DFT
2
3 // i . e . W8∗ m a t r i x d e r i v a t i o n
4
5 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
6 //OS windows 10
7 clc ;
8 clear ;
9 // Computing t h e t w i d d l e f a c t o r v a l u e s f o r W80 , W81 ,
W82 , W83 , W84 , W85 , W86 , W87 :
10 W80 = int ( cos (0) ) +( sqrt ( -1) * int ( sin (0) ) ) ;
11 W81 = cos ((2* %pi *1) /8) +( sqrt ( -1) ) * sin ((2* %pi *1) /8) ;
12 W82 = int ( cos ((2* %pi *2) /8) ) +( sqrt ( -1) ) * sin ((2* %pi *2)
/8) ;
13 W83 = cos ((2* %pi *3) /8) +( sqrt ( -1) ) * sin ((2* %pi *3) /8) ;
14 W84 = cos ((2* %pi *4) /8) +( sqrt ( -1) ) * int ( sin ((2* %pi *4) /8)

26
);
15 W85 = cos ((2* %pi *5) /8) +( sqrt ( -1) ) * sin ((2* %pi *5) /8) ;
16 W86 = int ( cos ((2* %pi *6) /8) ) +( sqrt ( -1) ) * sin ((2* %pi *6)
/8) ;
17 W87 = cos ((2* %pi *7) /8) +( sqrt ( -1) ) * sin ((2* %pi *7) /8) ;
18
19 disp ( W80 , ’W80= ’ )
20 disp ( W81 , ’W81= ’ )
21 disp ( W82 , ’W82= ’ )
22 disp ( W83 , ’W83= ’ )
23 disp ( W84 , ’W84= ’ )
24 disp ( W85 , ’W85= ’ )
25 disp ( W86 , ’W86= ’ )
26 disp ( W87 , ’W87= ’ )
27
28 //W80=W88=W816=W824=W832=W840=W848 ; / / C y c l i c p r o p e r t y
of twiddle factor
29 W88 = W80 ;
30 W816 = W88 ;
31 W824 = W816 ;
32 W832 = W824 ;
33 W840 = W832 ;
34 W848 = W840 ;
35
36 //W81=W89=W817=W825=W833=W841=W849 ; / / C y c l i c p r o p e r t y
of twiddle factor
37 W89 = W81 ;
38 W817 = W89 ;
39 W825 = W817 ;
40 W833 = W825 ;
41 W841 = W833 ;
42 W849 = W841 ;
43
44 //W82=W810=W818=W826=W834=W842 ; / / C y c l i c p r o p e r t y o f
twiddle factor
45 W810 = W82 ;
46 W818 = W810 ;
47 W826 = W818 ;

27
48 W834 = W826 ;
49 W842 = W834 ;
50
51 //W83=W811=W819=W827=W835=W843 ; / / C y c l i c p r o p e r t y o f
twiddle factor
52 W811 = W83 ;
53 W819 = W811 ;
54 W827 = W819 ;
55 W835 = W827 ;
56 W843 = W835 ;
57
58 //W84=W812=W820=W828=W836=W844 ; / / C y c l i c p r o p e r t y o f
twiddle factor
59 W812 = W84 ;
60 W820 = W812 ;
61 W828 = W820 ;
62 W836 = W828 ;
63 W844 = W836 ;
64
65 //W85=W813=W821=W829=W837=W845 ; / / C y c l i c p r o p e r t y o f
twiddle factor
66 W813 = W85 ;
67 W821 = W813 ;
68 W829 = W821 ;
69 W837 = W829 ;
70 W845 = W837 ;
71
72 //W86=W814=W822=W830=W838=W846 ; / / C y c l i c p r o p e r t y o f
twiddle factor
73 W814 = W86 ;
74 W822 = W814 ;
75 W830 = W822 ;
76 W838 = W830 ;
77 W846 = W838 ;
78
79 //W87=W815=W823=W831=W839=W847 ; / / C y c l i c p r o p e r t y o f
twiddle factor
80 W815 = W87 ;

28
81 W823 = W815 ;
82 W831 = W823 ;
83 W839 = W831 ;
84 W847 = W839 ;
85
86 W8_star = [ W80 W80 W80 W80 W80 W80 W80 W80 ; W80 W81
W82 W83 W84 W85 W86 W87 ; W80 W82 W84 W86 W88 W810
W812 W814 ; W80 W83 W86 W89 W812 W815 W818 W821 ; W80
W84 W88 W812 W816 W820 W824 W828 ; W80 W85 W810
W815 W820 W825 W830 W835 ; W80 W86 W812 W818 W824
W830 W836 W842 ; W80 W87 W814 W821 W828 W835 W842
W849 ];
87
88 disp ( W8_star , ’ [W8∗]= ’ )

29
Experiment: 9

Filtering Of Long Data


Sequences

Scilab code Solution 9.0 Experiment Number 9

1 //AIM : F i l t e r i n g o f l o n g d a t a s e q u e n c e s
2
3 // O v e r l a p −add method u s i n g FFT−IFFT t e c h n i q u e (
without using i n b u i l t S c i l a b
4 // f u n c t i o n s f o r DFT/IDFT o r FFT/IFFT )
5
6 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
7 //OS windows 10
8 clc ;
9 clear ;
10 // Given t h a t x ( n ) = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } and h ( n ) ={1 ,2}
11 // S o l n :
12 xn =[1 2 3 4 5 6 7 8]; //Nx=8
13 hn =[1 2];
14 // S i n c e Nx=8 ,Nh=2 and we know Nx=m∗Nh ( s o 8=m∗ 2 )
g i v i n g m=4; and s o x ( n ) h a s b e e n
15 // p a r t i t i o n e di n t o 4 b l o c k s o f l e n g t h Nh=2
16 x0n =[1 2];
17 x1n =[3 4];

30
18 x2n =[5 6];
19 x3n =[7 8];
20 // Length o f e a c h p a r t i t i o n e d i n p u t i . e x0n , x1n , x2n
and x3n i s 2 ( i . e . L=2)
21 // Here l e n g t h o f i m p u l s e r e s p o n s e a r r a y h ( n ) i s 2 ( i
. e . M=2) o r Nh=2
22 // Hence , we pad t h e p a r t i t i o n e d s e q u e n c e and h ( n )
with z e r o s such that the l e n g t h
23 // o f e a c h one becomes ’ a t l e a s t ’ L+M−1 i . e . 3
24 // But s i n c e we know 4 p o i n t DFT m a t r i x , we can pad an
a d d i t i o n a l z e r o & make t h e
25 // l e n g t h o f e a c h s e q u e n c e =4
26 x0n_z =[1 2 0 0]; // x 0 n z r e p r e s e n t s z e r o pad i s done
t o x0n
27 x1n_z =[3 4 0 0]; // x 1 n z r e p r e s e n t s z e r o pad i s done
t o x1n
28 x2n_z =[5 6 0 0]; // x 2 n z r e p r e s e n t s z e r o pad i s done
t o x2n
29 x3n_z =[7 8 0 0]; // x 3 n z r e p r e s e n t s z e r o pad i s done
t o x3n
30 hn_z =[1 2 0 0]; // h n z r e p r e s e n t s z e r o pad i s done t o
hn
31
32 // Computing FFT f o r x 0 n z
33 x0n_z_0 =1; // x 0 n z 0 r e p r e s e n t s t h e 0 t h s a m p l e o f
x0n z
34 x0n_z_1 =2; // x 0 n z 1 r e p r e s e n t s t h e 1 s t s a m p l e o f
x0n z
35 x0n_z_2 =0; // x 0 n z 2 r e p r e s e n t s t h e 2 nd s a m p l e o f
x0n z
36 x0n_z_3 =0; // x 0 n z 3 r e p r e s e n t s t h e 3 r d s a m p l e o f
x0n z
37 X0_0 =( x0n_z_2 + x0n_z_0 ) *(1) +( x0n_z_3 + x0n_z_1 ) *(1)
38 X0_1 =( x0n_z_3 - x0n_z_1 ) *( -1) *( - sqrt ( -1) ) +( x0n_z_2 -
x0n_z_0 ) *( -1) ;
39 X0_2 =(( x0n_z_3 + x0n_z_1 ) *(1) -( x0n_z_2 + x0n_z_0 ) *(1) )
*( -1) ;
40 X0_3 =(( x0n_z_3 - x0n_z_1 ) *( -1) *( - sqrt ( -1) ) -( x0n_z_2 -

31
x0n_z_0 ) *( -1) ) *( -1) ;
41 disp ({ , X0_0 , X0_1 , X0_2 , X0_3 ,} , ’ So , t h e DFT o f x0 ( n )
u s i n g D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m (
DIT−FFT) i s X0 ( k )= ’ )
42
43 // Computing FFT f o r x 1 n z
44 x1n_z_0 =3; // x 1 n z 0 r e p r e s e n t s t h e 0 t h s a m p l e o f
x1n z
45 x1n_z_1 =4; // x 1 n z 1 r e p r e s e n t s t h e 1 s t s a m p l e o f
x1n z
46 x1n_z_2 =0; // x 1 n z 2 r e p r e s e n t s t h e 2 nd s a m p l e o f
x1n z
47 x1n_z_3 =0; // x 1 n z 3 r e p r e s e n t s t h e 3 r d s a m p l e o f
x1n z
48 X1_0 =( x1n_z_2 + x1n_z_0 ) *(1) +( x1n_z_3 + x1n_z_1 ) *(1)
49 X1_1 =( x1n_z_3 - x1n_z_1 ) *( -1) *( - sqrt ( -1) ) +( x1n_z_2 -
x1n_z_0 ) *( -1) ;
50 X1_2 =(( x1n_z_3 + x1n_z_1 ) *(1) -( x1n_z_2 + x1n_z_0 ) *(1) )
*( -1) ;
51 X1_3 =(( x1n_z_3 - x1n_z_1 ) *( -1) *( - sqrt ( -1) ) -( x1n_z_2 -
x1n_z_0 ) *( -1) ) *( -1) ;
52 disp ({ , X1_0 , X1_1 , X1_2 , X1_3 ,} , ’ So , t h e DFT o f x1 ( n )
u s i n g D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m (
DIT−FFT) i s X1 ( k )= ’ )
53
54 // Computing FFT f o r x 2 n z
55 x2n_z_0 =5; // x 2 n z 0 r e p r e s e n t s t h e 0 t h s a m p l e o f
x2n z
56 x2n_z_1 =6; // x 2 n z 1 r e p r e s e n t s t h e 1 s t s a m p l e o f
x2n z
57 x2n_z_2 =0; // x 2 n z 2 r e p r e s e n t s t h e 2 nd s a m p l e o f
x2n z
58 x2n_z_3 =0; // x 2 n z 3 r e p r e s e n t s t h e 3 r d s a m p l e o f
x2n z
59 X2_0 =( x2n_z_2 + x2n_z_0 ) *(1) +( x2n_z_3 + x2n_z_1 ) *(1)
60 X2_1 =( x2n_z_3 - x2n_z_1 ) *( -1) *( - sqrt ( -1) ) +( x2n_z_2 -
x2n_z_0 ) *( -1) ;
61 X2_2 =(( x2n_z_3 + x2n_z_1 ) *(1) -( x2n_z_2 + x2n_z_0 ) *(1) )

32
*( -1) ;
62 X2_3 =(( x2n_z_3 - x2n_z_1 ) *( -1) *( - sqrt ( -1) ) -( x2n_z_2 -
x2n_z_0 ) *( -1) ) *( -1) ;
63 disp ({ , X2_0 , X2_1 , X2_2 , X2_3 ,} , ’ So , t h e DFT o f x2 ( n )
u s i n g D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m (
DIT−FFT) i s X2 ( k )= ’ )
64
65 // Computing FFT f o r x 3 n z
66 x3n_z_0 =7; // x 3 n z 0 r e p r e s e n t s t h e 0 t h s a m p l e o f
x3n z
67 x3n_z_1 =8; // x 3 n z 1 r e p r e s e n t s t h e 1 s t s a m p l e o f
x3n z
68 x3n_z_2 =0; // x 3 n z 2 r e p r e s e n t s t h e 2 nd s a m p l e o f
x3n z
69 x3n_z_3 =0; // x 3 n z 3 r e p r e s e n t s t h e 3 r d s a m p l e o f
x3n z
70 X3_0 =( x3n_z_2 + x3n_z_0 ) *(1) +( x3n_z_3 + x3n_z_1 ) *(1)
71 X3_1 =( x3n_z_3 - x3n_z_1 ) *( -1) *( - sqrt ( -1) ) +( x3n_z_2 -
x3n_z_0 ) *( -1) ;
72 X3_2 =(( x3n_z_3 + x3n_z_1 ) *(1) -( x3n_z_2 + x3n_z_0 ) *(1) )
*( -1) ;
73 X3_3 =(( x3n_z_3 - x3n_z_1 ) *( -1) *( - sqrt ( -1) ) -( x3n_z_2 -
x3n_z_0 ) *( -1) ) *( -1) ;
74 disp ({ , X3_0 , X3_1 , X3_2 , X3_3 ,} , ’ So , t h e DFT o f x3 ( n )
u s i n g D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m (
DIT−FFT) i s X3 ( k )= ’ )
75
76 // Computing FFT f o r h n z
77 hn_z_0 =1; // h n z 0 r e p r e s e n t s t h e 0 t h s a m p l e o f h n z
78 hn_z_1 =2; // h n z 1 r e p r e s e n t s t h e 1 s t s a m p l e o f h n z
79 hn_z_2 =0; // h n z 2 r e p r e s e n t s t h e 2 nd s a m p l e o f h n z
80 hn_z_3 =0; // h n z 3 r e p r e s e n t s t h e 3 r d s a m p l e o f h n z
81 Hk_0 =( hn_z_2 + hn_z_0 ) *(1) +( hn_z_3 + hn_z_1 ) *(1)
82 Hk_1 =( hn_z_3 - hn_z_1 ) *( -1) *( - sqrt ( -1) ) +( hn_z_2 - hn_z_0
) *( -1) ;
83 Hk_2 =(( hn_z_3 + hn_z_1 ) *(1) -( hn_z_2 + hn_z_0 ) *(1) ) *( -1) ;
84 Hk_3 =(( hn_z_3 - hn_z_1 ) *( -1) *( - sqrt ( -1) ) -( hn_z_2 -
hn_z_0 ) *( -1) ) *( -1) ;

33
85 disp ({ , Hk_0 , Hk_1 , Hk_2 , Hk_3 ,} , ’ So , t h e DFT o f h ( n )
u s i n g D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m (
DIT−FFT) i s H( k )= ’ )
86
87 Y0k0 =( X0_0 ) .*( Hk_0 ) ;
88 Y0k1 =( X0_1 ) .*( Hk_1 ) ;
89 Y0k2 =( X0_2 ) .*( Hk_2 ) ;
90 Y0k3 =( X0_3 ) .*( Hk_3 ) ;
91 Y0k =[ Y0k0 Y0k1 Y0k2 Y0k3 ];
92 disp ( Y0k , ’ Y0 ( k )= ’ )
93
94 // Computing IDFT o f Y0k u s i n g IDIT−FFT :
95
96 Y0k0_0c = real ( Y0k0 ) -( sqrt ( -1) ) * imag ( Y0k0 ) ; // Y0K0 0c
means c o m p l e x c o n j u g a t e o f Y0k0
97 Y0k0_1c = real ( Y0k1 ) -( sqrt ( -1) ) * imag ( Y0k1 ) ; // Y0K0 1c
means c o m p l e x c o n j u g a t e o f Y0k1
98 Y0k0_2c = real ( Y0k2 ) -( sqrt ( -1) ) * imag ( Y0k2 ) ; // Y0K0 2c
means c o m p l e x c o n j u g a t e o f Y0k2
99 Y0k0_3c = real ( Y0k3 ) -( sqrt ( -1) ) * imag ( Y0k3 ) ; // Y0K0 3c
means c o m p l e x c o n j u g a t e o f Y0k3
100
101 a0 =((( Y0k0_3c + Y0k0_1c ) *(1) ) +(( Y0k0_2c + Y0k0_0c ) *(1) ) )
*(1/4) ;
102 a1 =((( Y0k0_3c - Y0k0_1c ) *( -1) *( - sqrt ( -1) ) ) +( Y0k0_2c -
Y0k0_0c ) *( -1) ) *(1/4) ;
103 a2 =((( Y0k0_3c + Y0k0_1c ) *(1) -( Y0k0_2c + Y0k0_0c ) ) *( -1) )
*(1/4) ;
104 a3 =(((( Y0k0_3c - Y0k0_1c ) *( -1) *( - sqrt ( -1) ) ) -(( Y0k0_2c -
Y0k0_0c ) *( -1) ) ) *( -1) ) *(1/4) ;
105
106 a0_real = real ( a0 ) ;
107 a0_conj =( -1) *( imag ( a0 ) ) ;
108 a1_real = real ( a1 ) ;
109 a1_conj =( -1) *( imag ( a1 ) ) ;
110 a2_real = real ( a2 ) ;
111 a2_conj =( -1) *( imag ( a2 ) ) ;
112 a3_real = real ( a3 ) ;

34
113 a3_conj =( -1) *( imag ( a3 ) ) ;
114 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x
115 // c o n j u g a t e i s t a k e n
116 a0 ’= a0_real + a0_conj
117 a1 ’= a1_real + a1_conj
118 a2 ’= a2_real + a2_conj
119 a3 ’= a3_real + a3_conj
120 a =[ a0 ’ , a1 ’ , a2 ’ , a3 ’]
121 disp (a , ’ So , t h e IDFT o f Y0 ( k ) u s i n g I n v e r s e
D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m ( IDIT−
FFT) i s y0 ( n )= ’ )
122
123 Y1k0 =( X1_0 ) .*( Hk_0 ) ;
124 Y1k1 =( X1_1 ) .*( Hk_1 ) ;
125 Y1k2 =( X1_2 ) .*( Hk_2 ) ;
126 Y1k3 =( X1_3 ) .*( Hk_3 ) ;
127 Y1k =[ Y1k0 Y1k1 Y1k2 Y1k3 ];
128 disp ( Y1k , ’ Y1 ( k )= ’ )
129
130 // Computing IDFT o f Y1k u s i n g IDIT−FFT :
131 Y1k0_0c = real ( Y1k0 ) -( sqrt ( -1) ) * imag ( Y1k0 ) ; // Y1K0 0c
means c o m p l e x c o n j u g a t e o f Y1k0
132 Y1k0_1c = real ( Y1k1 ) -( sqrt ( -1) ) * imag ( Y1k1 ) ; // Y1K0 1c
means c o m p l e x c o n j u g a t e o f Y1k1
133 Y1k0_2c = real ( Y1k2 ) -( sqrt ( -1) ) * imag ( Y1k2 ) ; // Y1K0 2c
means c o m p l e x c o n j u g a t e o f Y1k2
134 Y1k0_3c = real ( Y1k3 ) -( sqrt ( -1) ) * imag ( Y1k3 ) ; // Y1K0 3c
means c o m p l e x c o n j u g a t e o f Y1k3
135
136 b0 =((( Y1k0_3c + Y1k0_1c ) *(1) ) +(( Y1k0_2c + Y1k0_0c ) *(1) ) )
*(1/4) ;
137 b1 =((( Y1k0_3c - Y1k0_1c ) *( -1) *( - sqrt ( -1) ) ) +( Y1k0_2c -
Y1k0_0c ) *( -1) ) *(1/4) ;
138 b2 =((( Y1k0_3c + Y1k0_1c ) *(1) -( Y1k0_2c + Y1k0_0c ) ) *( -1) )
*(1/4) ;
139 b3 =(((( Y1k0_3c - Y1k0_1c ) *( -1) *( - sqrt ( -1) ) ) -(( Y1k0_2c -
Y1k0_0c ) *( -1) ) ) *( -1) ) *(1/4) ;

35
140
141 b0_real = real ( b0 ) ;
142 b0_conj =( -1) *( imag ( b0 ) ) ;
143 b1_real = real ( b1 ) ;
144 b1_conj =( -1) *( imag ( b1 ) ) ;
145 b2_real = real ( b2 ) ;
146 b2_conj =( -1) *( imag ( b2 ) ) ;
147 b3_real = real ( b3 ) ;
148 b3_conj =( -1) *( imag ( b3 ) ) ;
149 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x
150 // c o n j u g a t e i s t a k e n
151 b0 ’= b0_real + b0_conj
152 b1 ’= b1_real + b1_conj
153 b2 ’= b2_real + b2_conj
154 b =[ b0 ’ , b1 ’ , b2 ’ , b3 ’]
155 disp (b , ’ So , t h e IDFT o f Y1 ( k ) u s i n g I n v e r s e
D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m ( IDIT−
FFT) i s y1 ( n )= ’ )
156
157 Y2k0 =( X2_0 ) .*( Hk_0 ) ;
158 Y2k1 =( X2_1 ) .*( Hk_1 ) ;
159 Y2k2 =( X2_2 ) .*( Hk_2 ) ;
160 Y2k3 =( X2_3 ) .*( Hk_3 ) ;
161 Y2k =[ Y2k0 Y2k1 Y2k2 Y2k3 ];
162 disp ( Y2k , ’ Y2 ( k )= ’ )
163
164 // Computing IDFT o f Y2k u s i n g IDIT−FFT :
165 Y2k0_0c = real ( Y2k0 ) -( sqrt ( -1) ) * imag ( Y2k0 ) ; // Y2K0 0c
means c o m p l e x c o n j u g a t e o f Y2k0
166 Y2k0_1c = real ( Y2k1 ) -( sqrt ( -1) ) * imag ( Y2k1 ) ; // Y2K0 1c
means c o m p l e x c o n j u g a t e o f Y2k1
167 Y2k0_2c = real ( Y2k2 ) -( sqrt ( -1) ) * imag ( Y2k2 ) ; // Y2K0 2c
means c o m p l e x c o n j u g a t e o f Y2k2
168 Y2k0_3c = real ( Y2k3 ) -( sqrt ( -1) ) * imag ( Y2k3 ) ; // Y2K0 3c
means c o m p l e x c o n j u g a t e o f Y2k3
169
170 c0 =((( Y2k0_3c + Y2k0_1c ) *(1) ) +(( Y2k0_2c + Y2k0_0c ) *(1) ) )

36
*(1/4) ;
171 c1 =((( Y2k0_3c - Y2k0_1c ) *( -1) *( - sqrt ( -1) ) ) +( Y2k0_2c -
Y2k0_0c ) *( -1) ) *(1/4) ;
172 c2 =((( Y2k0_3c + Y2k0_1c ) *(1) -( Y2k0_2c + Y2k0_0c ) ) *( -1) )
*(1/4) ;
173 c3 =(((( Y2k0_3c - Y2k0_1c ) *( -1) *( - sqrt ( -1) ) ) -(( Y2k0_2c -
Y2k0_0c ) *( -1) ) ) *( -1) ) *(1/4) ;
174
175 c0_real = real ( c0 ) ;
176 c0_conj =( -1) *( imag ( c0 ) ) ;
177 c1_real = real ( b1 ) ;
178 c1_conj =( -1) *( imag ( c1 ) ) ;
179 c2_real = real ( c2 ) ;
180 c2_conj =( -1) *( imag ( c2 ) ) ;
181 c3_real = real ( c3 ) ;
182 c3_conj =( -1) *( imag ( c3 ) ) ;
183 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x
184 // c o n j u g a t e i s t a k e n
185 c0 ’= c0_real + c0_conj
186 c1 ’= c1_real + c1_conj
187 c2 ’= c2_real + c2_conj
188 c3 ’= c3_real + c3_conj
189 c =[ c0 ’ , c1 ’ , c2 ’ , c3 ’]
190 disp (c , ’ So , t h e IDFT o f Y2 ( k ) u s i n g I n v e r s e
D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m ( IDIT−
FFT) i s y2 ( n )= ’ )
191
192 Y3k0 =( X3_0 ) .*( Hk_0 ) ;
193 Y3k1 =( X3_1 ) .*( Hk_1 ) ;
194 Y3k2 =( X3_2 ) .*( Hk_2 ) ;
195 Y3k3 =( X3_3 ) .*( Hk_3 ) ;
196 Y3k =[ Y3k0 Y3k1 Y3k2 Y3k3 ];
197 disp ( Y3k , ’ Y3 ( k )= ’ )
198
199 // Computing IDFT o f Y3k u s i n g IDIT−FFT :
200 Y3k0_0c = real ( Y3k0 ) -( sqrt ( -1) ) * imag ( Y3k0 ) ; // Y3K0 0c
means c o m p l e x c o n j u g a t e o f Y3k0

37
201 Y3k0_1c = real ( Y3k1 ) -( sqrt ( -1) ) * imag ( Y3k1 ) ; // Y3K0 1c
means c o m p l e x c o n j u g a t e o f Y3k1
202 Y3k0_2c = real ( Y3k2 ) -( sqrt ( -1) ) * imag ( Y3k2 ) ; // Y3K0 2c
means c o m p l e x c o n j u g a t e o f Y3k2
203 Y3k0_3c = real ( Y3k3 ) -( sqrt ( -1) ) * imag ( Y3k3 ) ; // Y3K0 3c
means c o m p l e x c o n j u g a t e o f Y3k3
204
205 d0 =((( Y3k0_3c + Y3k0_1c ) *(1) ) +(( Y3k0_2c + Y3k0_0c ) *(1) ) )
*(1/4) ;
206 d1 =((( Y3k0_3c - Y3k0_1c ) *( -1) *( - sqrt ( -1) ) ) +( Y3k0_2c -
Y3k0_0c ) *( -1) ) *(1/4) ;
207 d2 =((( Y3k0_3c + Y3k0_1c ) *(1) -( Y3k0_2c + Y3k0_0c ) ) *( -1) )
*(1/4) ;
208 d3 =(((( Y3k0_3c - Y3k0_1c ) *( -1) *( - sqrt ( -1) ) ) -(( Y3k0_2c -
Y3k0_0c ) *( -1) ) ) *( -1) ) *(1/4) ;
209
210 d0_real = real ( d0 ) ;
211 d0_conj =( -1) *( imag ( d0 ) ) ;
212 d1_real = real ( d1 ) ;
213 d1_conj =( -1) *( imag ( d1 ) ) ;
214 d2_real = real ( d2 ) ;
215 d2_conj =( -1) *( imag ( d2 ) ) ;
216 d3_real = real ( d3 ) ;
217 d3_conj =( -1) *( imag ( d3 ) ) ;
218 // F i n a l l y , we w i l l add t h e r e a l p a r t and t h e
i m a g i n a r y p a r t whose c o m p l e x
219 // c o n j u g a t e i s t a k e n
220 d0 ’= d0_real + d0_conj
221 d1 ’= d1_real + d1_conj
222 d2 ’= d2_real + d2_conj
223 d3 ’= d3_real + d3_conj
224 d =[ d0 ’ , d1 ’ , d2 ’ , d3 ’]
225 disp (d , ’ So , t h e IDFT o f Y3 ( k ) u s i n g I n v e r s e
D e c i m a t i o n −i n −Time F a s t F o u r i e r T r a n s f o r m ( IDIT−
FFT) i s y3 ( n )= ’ )
226 w =[ a 0 0 0 0 0 0];
227 x =[0 0 b 0 0 0 0];
228 y =[0 0 0 0 c 0 0];

38
229 z =[0 0 0 0 0 0 d ];
230 disp (z ,y ,x ,w , ’ A f t e r o v e r l a p p i n g , t h e s e q u e n c e s will
be s e e n a s f o l l o w s : ’ )
231 yn = w + x + y + z ;
232 disp ( yn , ’ The o u t p u t : y ( n )= ’ )

39
Experiment: 10

Implement Impulse Invariant


Method

Scilab code Solution 10.0 Experiment Number 10

1 //AIM : Implement I m p u l s e I n v a r i a n t method


2
3 // Find o u t H( z ) u s i n g i m p u l s e i n v a r i a n c e s method a t
5Hz s a m p l i n g f r e q u e n c y
4 // from H( s ) where H( s ) =1/( s +1) ( s +2)
5
6 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
7 //OS windows 10
8 clc ;
9 clear ;
10 s = %s ;
11 s2 = -2;
12 s1 = -1;
13 d1 =( s - s1 ) ;
14 p2 =( s - s2 ) ;
15 if ( s1 ) then // When p o l e =−1
16 s1 = -1;
17 s2 = -2;
18 s = s1 ;

40
19 d2 =( s - s2 ) ;
20 num1 =1/ d2 ; // V a l u e o f A1
21 h1 = syslin ( ’ c ’ , num1 / d1 )
22 end
23 disp ( h1 )
24 disp ( num1 , ’ v a l u e o f A1= ’ )
25 if ( s2 ) then // When p o l e =−2
26 s1 = -1;
27 s2 = -2;
28 s = s2 ;
29 p1 =( s - s1 ) ;
30 num2 =1/ p1 ; // V a l u e o f A2
31 h2 = syslin ( ’ c ’ , num2 / p2 )
32 end
33 disp ( h2 )
34 disp ( num2 , ’ V a l u e o f A2= ’ )
35 Hs =( h1 ) +( h2 ) ;
36 disp ( Hs , ’ T r a n s f e r f u n c t i o n o f a n a l o g f i l t e r H( s )= ’ )
37 // O b t a i n t h e Z−t r a n s f o r m u s i n g i m p u l s e i n v a r i a n c e
transformation equation
38 // 1 / ( s−pk ) =1/[1 − exp ( pk ∗ Ts ) ∗Zˆ( −1) ]
39 Fs =5;
40 Ts =1/ Fs ;
41 disp ( ’ s e c ’ ,Ts , ’ S a m p l i n g t i m e Ts= ’ )
42 // we have p o l e s a t s 1=−1 and s 2=−2
43 Z = poly (0 , ”Z” )
44 // 1 / ( s +1)=a ; We c o n s i d e r
45 a = num1 /(1 - exp ( s1 *( Ts ) ) * Z ^( -1) ) ;
46 // 1 / ( s +2)=b ; We c o n s i d e r
47 b = num2 /(1 - exp ( s2 *( Ts ) ) * Z ^( -1) ) ;
48 disp (a , ’ 1/ s+1= ’ )
49 disp (b , ’ 1/ s+2= ’ )
50 // The T r a n s f e r f u n c t i o n o f d i g i t a l f i l t e r i s g i v e n
by ,
51 //H( Z )= ( k =1) ˆN( Ak/(1 − e ˆ ( pk ∗ Ts ) ∗Zˆ( −1) )
52 //H( Z )=A1/1− exp ( p1 ∗ Ts ) ∗Zˆ( −1)+A2/1− exp ( p1 ∗ Ts ) ∗Zˆ( −1)
53 Hz =( a + b ) ;
54 disp ( Hz , ’ The r e q u i r e d t r a n s f e r f u n c t i o n f o r d i g i t a l

41
I I R f i l t e r H( Z )= ’ )

42
Experiment: 11

To Design Butterworth Filter


With Minimum Readymade
Scilab Functions

Scilab code Solution 11.0 Experiment Number 11

1 //AIM : To d e s i g n B u t t e r w o r t h f i l t e r w i t h minimum
readymade S c i l a b f u n c t i o n s
2
3 //To compute t h e o r d e r and t h e p o l e s o f B u t t e r w o r t h
low p a s s f i l t e r u s i n g
4 // B i l i n e a r t r a n s f o r m a t i o n (ASSUME T=1SEC ) ;
5 // A t t e n u a t i o n i n p a s s b a n d =1.93dB
6 // A t t e n u a t i o n i n s t o p b a n d = 1 3 . 9 7 dB
7 // Passband e d g e f r e q u e n c y =0.2
8 // Stopbandband e d g e f r e q u e n c y =0.6
9
10 // S o f t w a r e v e r s i o n Scilab 5.5.2
11 //OS windows 10
12 clc ;
13 clear ;
14 s = poly (0 , ” s ” )
15 T =1;

43
16 Ap =1.93; // i n dB
17 As =13.97; // i n dB
18 wp =0.2*( %pi )
19 ws =0.6*( %pi )
20 ohmp =2/ T *( tan ( wp /2) )
21 ohms =2/ T *( tan ( ws /2) )
22 //ORDER CALCULATION :
23 N =(0.5) *( log ((((10^(0.1* As ) ) -1) /((10^(0.1* Ap ) ) -1) ) ) )
/( log ( ohms / ohmp ) )
24
25 Nr = int ( N )
26 x =N - int ( N )
27 if (x >0)
28 Nr = Nr +1
29 ohmc =( ohmp /(10^(0.1* Ap ) -1) ^(1/(2* Nr ) ) )
30 // C a l c u l a t i o n o f p o l e s
31 i =0:1: Nr -1;
32 pi_plus = ohmc * exp ( %i *( Nr +2* i +1) *( %pi ) /(2* Nr ) )
33 pi_minus = - ohmc * exp ( %i *(2+2.* i +1) *( %pi ) /(2* Nr ) )
34 disp ( wp , ’ wp= ’ )
35 disp ( ws , ’ ws= ’ )
36 disp ( ohmp , ’ ohmp= ’ )
37 disp ( ohms , ’ ohms= ’ )
38 disp (N , ’N= ’ )
39 disp ( Nr , ’ R o u n d o f f v a l u e o f N now d e n o t e d a s Nr = ’ )
40 disp ( ohmc , ’ C u t o f f f r e q u e n c y : ohmc= ’ )
41 disp ( ’ D i s p l a y i n g t h e p o l e s ’ )
42 disp ( pi_plus , ’ p i p l u s = ’ )
43 disp ( pi_minus , ’ p i m i n u s= ’ )
44 h2 = zeros (1 ,2)
45 h = ohmc /( s -( -0.53 -0.53* %i ) )
46 h1 = ohmc /( s -( -0.53+0.53* %i ) )
47 h2 = h * h1 ;
48 disp (h , h1 , ’Now t h e a n a l o g t r a n s f e r f u n c t i o n H( s ) i s
t h e m u l t i p l i c a t i o n o f t h e f o l l o w i n g two t e r m s : ’ )
;
49 disp ( h2 , ’ A f t e r m u l t i p l i c a t i o n , H( s )= ’ )
50 g = numer ( h2 ) ;

44
51 disp (g , ’ Numerator o f t h e a n a l o g t r a n s f e r f u n c t i o n= ’ )
52 // O b t a i n i n g H( z ) u s i n g B i l i n e a r T r a n s f o r m a t i o n
Method :
53 z = poly (0 , ” z ” )
54 s =(2/ T ) *(( z -1) /( z +1) ) ; // B i l i n e a r T r a n s f o r m a t i o n
Method
55 disp ( ’ Type r e s u m e i n C o n s o l e ’ )
56 pause
57 a =0.5618 +1.06* s + s ^2;
58 b =(1/ a )
59 c =0.5645360* b ;
60 disp (c , ’ The d i g i t a l t r a n s f e r f u n c t i o n H( z )= ’ )

45
Experiment: 12

To Design Chebyshev Filter


With Minimum Readymade
Scilab Functions.

Scilab code Solution 12.0 Experiment Number 12

1 //AIM : To d e s i g n Chebyshev f i l t e r w i t h minimum


readymade S c i l a b f u n c t i o n s
2
3 // D e s i g n o f low p a s s 1 r a d / s e c bandwidth Chebyshev
filter
4 // A c c e p t a b l e p a s s b a n d r i p p l e =2 db
5 // c u t o f f r a d i a n f r e q u e n c y 1 r a d i a n / s e c
6 // s t o p band a t t e n u a t i o n o f 20 db o r g r e a t e r beyond
1.3 radian / sec
7
8 // S o f t w a r e v e r s i o n S c i l a b 5.5.2
9 //OS windows 10
10 clc ;
11 clear ;
12 // Given cut − o f f f r e q u e n c y i s 1 r a d / s e c . T h i s means
t h a t i t i s a n o r m a l i z e d low
13 // p a s s Chebyshev f i l t e r

46
14 fc =1; // from t h e a b o v e q u e s t i o n
15 Ap =2; // from t h e a b o v e q u e s t i o n
16 As =20; // from t h e a b o v e q u e s t i o n
17 ohms =1.3; // from t h e a b o v e q u e s t i o n
18 ohmp =1; // I t i s a n o r m a l i z e d f i l t e r . Hence t h e v a l u e
i s 1 rad / s e c
19
20 // S t e p s f o r c a l c u l a t i o n o f
21 a =(0.1*2)
22 b =10^ a
23 c =b -1
24 episelon = c ^(1/2)
25 disp ( episelon , ” =” )
26
27 // S t e p s f o r c a l c u l a t i o n o f o r d e r
28 d =( -20) *(( log ( episelon ) / log (10) ) )
29 e =(20) *( log ( ohms ) / log (10) )
30 f =6+ e
31 g =26+ d
32 N=g/f
33 Nr = int ( N )
34 x =N - int ( N )
35 if (x >0)
36 Nr = Nr +1
37 //N=((( −20) ∗ l o g ( e p i s e l o n ) ) +6+20) / ( 6 + 2 0 ∗ ( l o g ( ohms ) ) )
38 D = -20; // g i v e n i n db
39 //N=−(20∗ l o g 1 0 ( e p i s e l o n ) ) −6(N−1) −(20∗ l o g ( ohms ) )
40 h1 =(( episelon ) ^2)
41 h2 =1+ h1
42 h3 = h2 ^(1/2)
43 h4 = h3 +1
44 g =( episelon )
45 h5 = h4 / g
46 beta =( h5 ) ^(1/ Nr )
47 disp (N , ”N=” )
48 disp ( Nr , ” The round− o f f v a l u e o f N( now c a l l e d a s Nr )=
”)
49 disp ( beta , ” =” )

47
50
51 // f o r t h e d e t e r m i n a t i o n o f p o l e s we have
52 r =( ohmp ) *((( beta ^2) -1) /(2* beta ) )
53 disp (r , ” The minor a x i s o f t h e e l l i p s e ( r )=” )
54 R = ohmp *(( beta ^2+1) /(2* beta ) )
55 disp (R , ” The m a j o r a x i s o f t h e e l l i p s e (R)=” ) ;
56 // t h e t a i =(%pi / 2 ) +((2 i +%pi ) /2∗N) // i =0123
57 // f o r i =0
58 theta0 =(( %pi /2) +((2*0* %pi + %pi ) /(2*4) ) )
59 disp ( theta0 , ” t h e t a 0=” )
60 // f o r i =1
61 theta1 =(( %pi /2) +((2*1* %pi + %pi ) /(2*4) ) )
62 disp ( theta1 , ” t h e t a 1=” )
63 // f o r i =2
64 theta2 =(( %pi /2) +((2*2* %pi + %pi ) /(2*4) ) )
65 disp ( theta2 , ” t h e t a 2=” )
66 // f o r i =3
67 theta3 =(( %pi /2) +((2*3* %pi + %pi ) /(2*4) ) )
68 disp ( theta3 , ” t h e t a 3=” )
69 // t h e p o l e p o s i t i o n i s g i v e n by
70 // s p=r ∗ c o s ( t h e t a i )+ j s i n ( t h e t a i )
71 i =0:1: Nr -1
72 // Computing r e a l and i m a g i n a r y p a r t o f s0 , s1 , s2 , s 3
73 h6 =(( r ) *( cos ( theta0 ) ) ) // Computing r e a l p a r t o f s 0
74 h7 =( %i ) *( R ) *( sin ( theta0 ) ) // Computing i m a g i n a r y p a r t
of s0
75 s0 = h6 + h7 ; // Combining r e a l and i m a g i n a r y p a r t o f s 0
76 disp ( s0 , ” s 0=” )
77 h8 =(( r ) *( cos ( theta1 ) ) ) // Computing r e a l p a r t o f s 1
78 h9 =( %i ) *( R ) *( sin ( theta1 ) ) // Computing i m a g i n a r y p a r t
of s1
79 s1 = h8 + h9 ; // Combining r e a l and i m a g i n a r y p a r t o f s 1
80 disp ( s1 , ” s 1=” )
81 h10 =(( r ) *( cos ( theta2 ) ) ) // Computing r e a l p a r t o f s 2
82 h11 =( %i ) *( R ) *( sin ( theta2 ) ) // Computing i m a g i n a r y
part of s2
83 s2 = h10 + h11 ; // Combining r e a l and i m a g i n a r y p a r t o f
s2

48
84 disp ( s2 , ” s 2=” )
85 h12 =(( r ) *( cos ( theta3 ) ) ) // Computing r e a l p a r t o f s 3
86 h13 =( %i ) *( R ) *( sin ( theta3 ) ) // Computing i m a g i n a r y
part of s3
87 s3 = h12 + h13 ; // Combining r e a l and i m a g i n a r y p a r t o f
s13
88 disp ( s3 , ” s 3=” )
89
90 // C a l c u l a t i o n o f t r a n s f e r f u n c t i o n :
91 s = poly (0 , ” s ” )
92 h =1/(( s -( s0 ) ) *( s -( s1 ) ) *( s -( s2 ) ) *( s -( s3 ) ) )
93 disp (h , ” h=” )
94 disp ( ’Now t y p e r e s u m e and p r e s s e n t e r i n t h e C o n s o l e
window ’ )
95 pause
96 //Now v a l u e o f b0 i s r e q u i r e d which i s n o t h i n g but
the value of the constant
97 // term i n t h e d e n o m i n a t o r o f h ( o b t a i n e d by s e e i n g
the c a l c u l a t e d value in the
98 // c o n s o l e window by i n s e r t i n g a ’ pause ’ i n t h e
program )
99 b0 =0.2057651;
100 // A l s o we s e e i n t h e C o n s o l e window t h a t t h e r o u n d e d
value of the order i s 4
101 // and s i n c e 4 i s an e v e n number , s o t h e f o r m u l a f o r
c a l c u l a t i o n o f i w i l l be
102 // i=b0 / ( s q r t (1+ ˆ 2 ) )
103 i = b0 /( sqrt (1+( episelon ) ^2) )
104 disp (i , ’ i = ’ )
105 Hs = i * h // C a l c u l a t e d v a l u e o f Ha ( s )
106 disp ( Hs , ’ The r e q u i r e d t r a n s f e r f u n c t i o n Ha ( s )= ’ ) //
Displaying the c a l c u l a t e d value of the t r a n s f e r
function

49
Experiment: 13

Designing Two Stage


Decimator

Scilab code Solution 13.0 Experiment Number 13

1 //AIM : To i m p l e m e n t a two s t a g e d e c i m a t o r f o r t h e
following specifications :
2 // S a m p l i n g r a t e o f t h e i n p u t s i g n a l =20 ,000 Hz
3 //D=100 , Passband=0 t o 40 Hz , T r a n s i t i o n Band=40 t o 50
Hz , Passband r i p p l e = 0 . 0 2 , Stopband r i p p l e = 0 . 0 0 2
4
5 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
6 //OS windows 10
7 clc ;
8 clear ;
9
10 // L e t u s c o n s i d e r t h e c o m b i n a t i o n 2 5 ∗ 4
11 D1 =25;
12 D2 =4;
13 // s u c h t h a t D=D1∗D2
14 F0 =20000; // Fo i s t h e s a m p l i n g f r e q u e n c y ( o r s a m p l i n g
rate ) of the input s i g n a l ( given in the question )
15 Fp =40; // Fp i s t h e p a s s b a n d e d g e f r e q u e n c y ( g i v e n i n
the question )

50
16 Fstop =50; // F s t o p i s t h e s t o p b a n d e d g e f r e q u e n c y (
given in the question )
17 F1 = F0 / D1 ;
18 F2 = F1 / D2 ;
19 disp ( ” H e r t z ” ,F0 , ” The g i v e n v a l u e o f F0=” )
20 disp ( ” H e r t z ” ,F1 , ” The c a l c u l a t e d v a l u e o f F1=” )
21 disp ( ” H e r t z ” ,F2 , ” The c a l c u l a t e d v a l u e o f F2=” )
22 Dp =0.02;
23 Ds =0.002;
24 // c a l c u l a t i o n s f o r s t a g e I . . .
25 // S t e p 1 : Passband :0<=F<=Fp t h a t means 0<= F<= 40
Hertz
26 // S t e p 2 : Stopband : Fi−Fstop<=F<=F ( i −1) /2
27 // Here i =1 f o r S t a g e −I
28 LROS1 = F1 - Fstop ; // Here , LROS1=Lowest l i m i t o f
s t o p b a n d f o r S t a g e −I
29 HROS1 = F0 /2; // Here , HROS1=H i g h e s t l i m i t o f s t o p b a n d
f o r S t a g e −I
30 disp ( ” H e r t z ” , LROS1 , ” The l o w e s t l i m i t o f s t o p b a n d ( f o r
S t a g e −I ) =” )
31 disp ( ” H e r t z ” , HROS1 , ” The h i g h e s t l i m i t o f s t o p b a n d (
f o r S t a g e −I ) =” )
32 disp ( ” H e r t z ” , HROS1 , ”<=F<=” ,” H e r t z ” , LROS1 , ” So t h e
r a n g e o f s t o p b a n d f o r S t a g e I i s : ” ,)
33 Tmax1 = LROS1 ;
34 Tmin1 = Fp ;
35 DF1 =( Tmax1 - Tmin1 ) / F0
36 Dp1 =( Dp /2) ;
37 Ds1 = Ds ;
38 disp ( ’ H e r t z ’ ,DF1 , ” The c a l c u l a t e d v a l u e o f F1 =” )
39 disp ( Dp1 , ” The c a l c u l a t e d v a l u e o f p1 =” )
40 disp ( Ds1 , ” The v a l u e o f s1 = s =” )
41 N1 =((( -10* log10 ( Dp1 * Ds1 ) -13) /(14.6* DF1 ) ) +1) ; //
Computing t h e f i l t e r l e n g t h ( N1 ) o f S t a g e −I
42 disp ( N1 , ” F i l t e r l e n g t h , N1=” )
43 NR1 = int ( N1 ) ; // E x t r a c t i n g o n l y t h e i n t e g e r p a r t from
N1
44 x1 = N1 - int ( N1 ) ; // x1 i s t h e d e c i m a l p a r t o f o v e r a l l N1

51
45 if ( x1 >0) // I f t h e d e c i m a l p a r t i s g r e a t e r t h a n z e r o
46 NR1 = NR1 +1 // Then i n c r e m e n t t h e e x t r a c t e d i n t e g e r
p a r t i . e . NR1 by 1 t o g e t a round− o f f v a l u e
o f t h e l e n g t h o f f i l t e r o f S t a g e −I
47 disp ( NR1 , ” F i l t e r l e n g t h N1 ( round− o f f v a l u e ) now known
a s NR1=” )
48 // c a l c u l a t i o n s f o r s t a g e − I I . . .
49 // S t e p 1 : Passband :0<=F<=Fp t h a t means 0<= F<= 40
Hertz
50 // S t e p 2 : Stopband : Fi−Fstop<=F<=F ( i −1) /2
51 // Here i =2 f o r S t a g e − I I
52 disp ( ”−−−−−−−−−−−−−−Now d i s p l a y i n g t h e v a l u e s f o r
s t a g e −I I −−−−−−−−−−−−−−” )
53 LROS2 = F2 - Fstop ; // Here , LROS2=Lowest l i m i t o f
stopband f o r Stage −I I
54 HROS2 = F1 /2 // Here , HROS2=H i g h e s t l i m i t o f s t o p b a n d
f o r Stage −I I
55 disp ( ” H e r t z ” , LROS2 , ” The l o w e s t l i m i t o f s t o p b a n d ( f o r
S t a g e − I I ) =” )
56 disp ( ” H e r t z ” , HROS2 , ” The h i g h e s t l i m i t o f s t o p b a n d (
f o r S t a g e − I I ) =” )
57 disp ( ” H e r t z ” , HROS2 , ”<=F<=” ,” H e r t z ” , LROS2 , ” So t h e
r a n g e o f s t o p b a n d f o r S t a g e − I I i s : ” ,)
58 // I f t r a n s i t i o n band i s g i v e n i n t h e q u e s t i o n , t h e n
always g i v e n t r a n s i t i o n width i s a p p l i c a b l e f o r
the second stage .
59 // Given t r a n s i t i o n w i d t h i s 40 Hz t o 50 Hz .
60 // I t i n d i c a t e s t h a t f o r t h i s s t a g e , t h e s t o p b a n d
s h o u l d s t a r t a t 50 Hz .
61 a =50;
62 disp ( ” H e r t z ” ,a , ” The new v a l u e o f t h e l o w e s t l i m i t o f
s t o p b a n d ( f o r S t a g e − I I ) =” )
63 disp ( ” H e r t z ” , HROS2 , ” The h i g h e s t l i m i t o f s t o p b a n d i s
r e −w r i t t e n ( f o r S t a g e − I I ) which i s =” )
64 disp ( ” H e r t z ” , HROS2 , ”<=F<=” ,” H e r t z ” ,a , ” So t h e new
m o d i f i e d r a n g e o f s t o p b a n d f o r S t a g e − I I i s : ” ,)
65 Tmax2 =50;
66 Tmin2 = Fp ;

52
67 DF2 =( Tmax2 - Tmin2 ) / F1
68 Dp2 =( Dp /2) ;
69 Ds2 = Ds ;
70 disp ( ’ H e r t z ’ ,DF2 , ” The c a l c u l a t e d v a l u e o f F2 =” )
71 disp ( Dp2 , ” The c a l c u l a t e d v a l u e o f p2 =” )
72 disp ( Ds2 , ” The v a l u e o f s2 = s1 = s =” )
73 N2 =((( -10* log10 ( Dp2 * Ds2 ) -13) /(14.6* DF2 ) ) +1) ; //
Computing t h e f i l t e r l e n g t h ( N2 ) o f S t a g e − I I
74 disp ( N2 , ” F i l t e r l e n g t h , N2=” )
75 NR2 = int ( N2 ) ; // E x t r a c t i n g o n l y t h e i n t e g e r p a r t from
N2
76 x2 = N2 - int ( N2 ) ; // x i s t h e d e c i m a l p a r t o f o v e r a l l N2
77 if ( x2 >0) // I f t h e d e c i m a l p a r t i s g r e a t e r t h a n z e r o
78 NR2 = NR2 +1 // Then i n c r e m e n t t h e e x t r a c t e d i n t e g e r
p a r t i . e . NR2 by 1 t o g e t a round− o f f v a l u e
o f the l e n g t h o f f i l t e r o f Stage −I I
79 disp ( NR2 , ” F i n a l f i l t e r l e n g t h , N2 ( round− o f f v a l u e ) now
known a s NR2=” )
80 // C a l c u l a t i o n o f MPS( M u l t i p l i c a t i o n s p e r s e c o n d ) and
TSR( T o t a l S t o r a g e r e q u i r e m e n t ) . . .
81 //MPS= o f [ i =1 t o I ] ( Ni ∗ F i )
82 // Here I=T o t a l No . o f s t a g e s =2
83 MPS =( NR1 * F1 ) +( NR2 * F2 ) ;
84 disp ( MPS , ” The v a l u e o f No . o f MPS( M u l t i p l i c a t i o n s
p e r s e c o n d )=” )
85 //TSR= o f [ i =1 t o I ] ( Ni )
86 // Here I=T o t a l No . o f s t a g e s =2
87 TSR = NR1 + NR2
88 disp ( TSR , ” The v a l u e o f TSR( T o t a l s t o r a g e r e q u i r e m e n t
)=” )

53
Experiment: 14

Compute Dft Using Matrix


Approach And Then Using Dft
Properties.

Scilab code Solution 14.0 Experiment Number 14

1 // Compute DFT u s i n g m a t r i x a p p r o a c h & t h e n u s i n g DFT


properties .
2 // ( i ) : x ( n ) = { 1 , 2 , 3 , 4 ) , f i n d DFT X( k )
3 // ( i i ) : Using r e s u l t s obtained in part ( i ) & not
otherwise ,
4 // f i n d DFT o f f o l l o w i n g s e q u e n c e s :
5 // x1 ( n ) = { 4 , 1 , 2 , 3 }
6 // x2 ( n ) = { 2 , 3 , 4 , 1 }
7 // x3 ( n ) = { 3 , 4 , 1 , 2 }
8 // x4 ( n ) = { 4 , 6 , 4 , 6 }
9 // S o f t w a r e v e r s i o n S c i l a b 5 . 5 . 2
10 //OS windows 10
11 clc ;
12 clear ;
13 // L e t u s f i r s t d e f i n e t h e W4 m a t r i x
14 W4 =[1 1 1 1 ;1 - sqrt ( -1) -1 sqrt ( -1) ;1 -1 1 -1;1
sqrt ( -1) -1 - sqrt ( -1) ];

54
15 disp ( W4 , ’W4= ’ )
16 //Now l e t u s d e f i n e t h e i n p u t s e q u e n c e
17 xn =[1;2;3;4]; // The i n p u t s e q u e n c e x ( n ) h a s b e e n
a r r a n g e d a s a column m a t r i x
18 //DFT i s o b t a i n e d by m u l t i p l y i n g t h e t w i d d l e m a t r i x
W4 and t h e i n p u t s e q u e n c e
19 Xk = W4 * xn ;
20 disp ( Xk , ’DFT : X( k )= ’ )
21 disp ( ’ Type r e s u m e i n c o n s o l e and p r e s s e n t e r ’ )
22 pause
23 X0 =10
24 X1 = -2+2* sqrt ( -1) ;
25 X2 = -2
26 X3 = -2 -2* sqrt ( -1) ;
27
28 // ( i i ) : x1 ( n ) = { 4 , 1 , 2 , 3 } and x ( n ) = { 1 , 2 , 3 , 4 }
29 // x1 ( n ) i s o b t a i n e d by d e l a y i n g x ( n ) by 1 p o s i t i o n
which means x1 ( n )=x ( n −1)
30 // A c c o r d i n g t o t h e c i r c u l a r t i m e s h i f t p r o p e r t y : x (
n− l ) g i v e s DFT a s X( k ) ∗ e ˆ(− j ∗2∗ %pi ∗ k ∗ l /N)
31 // But l =−1
32 a1 = cos (0) -( sqrt ( -1) * sin (0) ) ;
33 // So , f o r k =0 ,
34 X10 = X0 .* real ( a1 ) - X0 .*( sqrt ( -1) * imag ( a1 ) )
35 disp ( X10 , ’ X1 ( 0 )= ’ )
36 // So , f o r k =1 ,
37 b1 = int ( cos ( %pi /2) ) -( sqrt ( -1) * sin ( %pi /2) )
38 X11 = X1 * b1 ;
39 disp ( X11 , ’ X1 ( 1 )= ’ )
40 // For k =2 ,
41 c1 = int ( cos ( %pi ) ) - int (( sqrt ( -1) * sin ( %pi ) ) ) ;
42 X12 = X2 * c1 ;
43 disp ( X12 , ’ X1 ( 2 )= ’ )
44 // For k =3 ,
45 d1 = int ( cos ((3* %pi ) /2) ) - int (( sqrt ( -1) * sin ((3* %pi ) /2) )
);
46 X13 = X3 * d1 ;
47 disp ( X13 , ’ X1 ( 3 )= ’ )

55
48 disp ({ , X10 , X11 , X12 , X13 ,} , ’ So , X1 ( k )= ’ )
49
50 // ( i i i ) : Now moving ahead t o f i n d X2 ( k )
51 // x2 ( n ) = { 2 , 3 , 4 , 1 } and x ( n ) = { 1 , 2 , 3 , 4 }
52 // x2 ( n ) i s o b t a i n e d by a d v a n c i n g x ( n ) by 1 p o s i t i o n
which means x2 ( n )=x ( n+1)
53 // A c c o r d i n g t o t h e c i r c u l a r t i m e s h i f t p r o p e r t y : x (
n− l ) g i v e s DFT a s X( k ) ∗ e ˆ(− j ∗2∗ %pi ∗ k ∗ l /N)
54 // But l =2
55 a2 = cos (0) +( sqrt ( -1) * sin (0) ) ;
56 // So , f o r k =0 ,
57 X20 = X0 .* real ( a2 ) - X0 .*( sqrt ( -1) * imag ( a2 ) )
58 disp ( X20 , ’ X2 ( 0 )= ’ )
59 // So , f o r k =1 ,
60 b2 = int ( cos ( %pi /2) ) +( sqrt ( -1) * sin ( %pi /2) )
61 X21 = X1 * b2 ;
62 disp ( X21 , ’ X2 ( 1 )= ’ )
63 // For k =2 ,
64 c2 = int ( cos ( %pi ) ) + int (( sqrt ( -1) * sin ( %pi ) ) ) ;
65 X22 = X2 * c2 ;
66 disp ( X22 , ’ X2 ( 2 )= ’ )
67 // For k =3 ,
68 d2 = int ( cos ((3* %pi ) /2) ) + int (( sqrt ( -1) * sin ((3* %pi ) /2) )
);
69 X23 = X3 * d2 ;
70 disp ( X23 , ’ X2 ( 3 )= ’ )
71 disp ({ , X20 , X21 , X22 , X23 ,} , ’ So , X2 ( k )= ’ )
72
73 // ( i v ) : Now moving ahead t o f i n d X3 ( k )
74 // x3 ( n ) = { 3 , 4 , 1 , 2 } and x ( n ) = { 1 , 2 , 3 , 4 }
75 // x3 ( n ) i s o b t a i n e d by s h i f t i n g x ( n ) by 2 p o s i t i o n s
which means x3 ( n )=x [ n(+/−) 2 ]
76 // A c c o r d i n g t o t h e c i r c u l a r t i m e s h i f t p r o p e r t y : x [
n(+/−) 2 ] g i v e s DFT a s X( k ) ∗ e ˆ(− j ∗2∗ %pi ∗ k ∗ l /N)
77 a3 = cos (0) +( sqrt ( -1) * sin (0) ) ;
78 // So , f o r k =0 ,
79 X30 = X0 .* real ( a3 ) - X0 .*( sqrt ( -1) * imag ( a3 ) )
80 disp ( X30 , ’ X3 ( 0 )= ’ )

56
81 // So , f o r k =1 ,
82 b3 = int ( cos ( %pi ) ) -( sqrt ( -1) * sin ( %pi ) )
83 X31 = X1 * b3 ;
84 disp ( X31 , ’ X3 ( 1 )= ’ )
85 // For k =2 ,
86 c3 = int ( cos (2* %pi ) ) - int (( sqrt ( -1) * sin (2* %pi ) ) ) ;
87 X32 = X2 * c3 ;
88 disp ( X32 , ’ X3 ( 2 )= ’ )
89 // For k =3 ,
90 d3 = int ( cos (3* %pi ) ) - int (( sqrt ( -1) * sin (3* %pi ) ) ) ;
91 X33 = X3 * d3 ;
92 disp ( X33 , ’ X3 ( 3 )= ’ )
93 disp ({ , X30 , X31 , X32 , X33 ,} , ’ So , X3 ( k )= ’ )
94
95 // ( v ) : Now moving ahead t o f i n d X4 ( k )
96 // x4 ( n ) = { 4 , 6 , 4 , 6 } and x ( n ) = { 1 , 2 , 3 , 4 }
97 // Both a r e r e l a t e d a s x4 ( n )=x ( n )+x [ n(+/−) 2 ]
98 // U s i n g h a l f p e r i o d s h i f t p r o p e r t y , X4 ( k )=X( k ) +[( −1)
ˆ k ] ∗X( k )
99 // For k =0 ,
100 X40 = X0 +[( -1) ^0]* X0
101 disp ( X40 , ’ X40= ’ )
102 // For k =1 ,
103 X41 = X1 +[( -1) ^1]* X1
104 disp ( X41 , ’ X41= ’ )
105 // For k =2 ,
106 X42 = X2 +[( -1) ^2]* X2
107 disp ( X42 , ’ X42= ’ )
108 // For k =3 ,
109 X43 = X3 +[( -1) ^3]* X3
110 disp ( X43 , ’ X43= ’ )
111 disp ({ , X40 , X41 , X42 , X43 ,} , ’ So , X4 ( k )= ’ )

57

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy