Scilab Companion for Signals and Systems
Scilab Companion for Signals and Systems
Created by
Satyam Agrawal
[Link]
Instrumentation Engineering
Krishna Institute Of Engineering and Technology
College Teacher
Varun Gupta
Cross-Checked by
Chaitanya
Author: P. R. Rao
Edition: 5
Year: 2011
ISBN: 978-0-07-066927-7
1
Scilab numbering policy used in this document and the relation to the
above book.
For example, Exa 3.51 means solved example 3.51 of this book. Sec 2.3 means
a scilab code whose theory is explained in Section 2.3 of the book.
2
Contents
7 Systems 113
3
List of Scilab Codes
4
Exa 2.39 Inverse Z Transform . . . . . . . . . . . . . . . . . . . 41
Exa 2.40 Inverse Z Transform . . . . . . . . . . . . . . . . . . . 41
Exa 3.13 Complex Fourier Exponential Series . . . . . . . . . . 43
Exa 3.14 Complex Fourier Exponential Series . . . . . . . . . . 49
Exa 3.16 Complex Fourier Exponential Series . . . . . . . . . . 50
Exa 3.17 Complex Fourier Exponential Series . . . . . . . . . . 54
Exa 3.18 Trignometric Series . . . . . . . . . . . . . . . . . . . . 55
Exa 4.1 Magnitude and Phase Spectra . . . . . . . . . . . . . . 56
Exa 4.2 Magnitude and Phase Spectra . . . . . . . . . . . . . . 60
Exa 4.3 Magnitude and Phase Spectra . . . . . . . . . . . . . . 65
Exa 4.4 Energy at output . . . . . . . . . . . . . . . . . . . . . 66
Exa 4.5 Fourier Transform . . . . . . . . . . . . . . . . . . . . 66
Exa 4.6 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 69
Exa 4.7 Energy in Signal . . . . . . . . . . . . . . . . . . . . . 71
Exa 4.11 Fourier Transform . . . . . . . . . . . . . . . . . . . . 72
Exa 4.14 Fourier Transform . . . . . . . . . . . . . . . . . . . . 72
Exa 4.17 Fourier Transform . . . . . . . . . . . . . . . . . . . . 75
Exa 5.1 DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Exa 5.2 DTFT and Spectra . . . . . . . . . . . . . . . . . . . . 80
Exa 5.3 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . 83
Exa 5.4 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . 86
Exa 5.5 Fourier series . . . . . . . . . . . . . . . . . . . . . . . 89
Exa 5.9.i DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Exa [Link] DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Exa [Link] DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Exa 5.11 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . 95
Exa 5.13 Circular Convolution . . . . . . . . . . . . . . . . . . . 96
Exa 5.14 Circular Convolution . . . . . . . . . . . . . . . . . . . 98
Exa 5.16 DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Exa 5.18 DFT coefficients . . . . . . . . . . . . . . . . . . . . . 100
Exa 6.1 Sampling and Reconstruction . . . . . . . . . . . . . . 101
Exa 6.2 Sampling and Reconstruction . . . . . . . . . . . . . . 102
Exa 6.3 Minimum Number of samples . . . . . . . . . . . . . . 106
Exa 6.4 Minimum Sampling Frequency . . . . . . . . . . . . . 108
Exa 6.5 LPF output . . . . . . . . . . . . . . . . . . . . . . . . 108
Exa 6.6 Sampling Frequency . . . . . . . . . . . . . . . . . . . 110
Exa 6.8 Minimum Sampling Frequency . . . . . . . . . . . . . 112
Exa 7.1 Properties of System . . . . . . . . . . . . . . . . . . . 113
5
Exa 7.3 System Properties . . . . . . . . . . . . . . . . . . . . 114
Exa 7.4 System Properties . . . . . . . . . . . . . . . . . . . . 115
Exa 7.5 System Properties . . . . . . . . . . . . . . . . . . . . 116
Exa 7.6 System Properties . . . . . . . . . . . . . . . . . . . . 117
Exa 7.7 Properties of System . . . . . . . . . . . . . . . . . . . 118
Exa 7.8 Properties of System . . . . . . . . . . . . . . . . . . . 119
Exa 7.9 Properties of System . . . . . . . . . . . . . . . . . . . 120
Exa 7.10 Output of an LTI . . . . . . . . . . . . . . . . . . . . 121
Exa 7.11 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 121
Exa 7.14 Impulse and Step response . . . . . . . . . . . . . . . 123
Exa 7.15 Impulse and Step Response . . . . . . . . . . . . . . . 125
Exa 7.19 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 128
Exa 7.22 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 131
Exa 7.23 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 134
Exa 7.24 Step Response . . . . . . . . . . . . . . . . . . . . . . 135
Exa 7.25 Step response . . . . . . . . . . . . . . . . . . . . . . . 137
Exa 7.33 Magnitude and Phase Response . . . . . . . . . . . . . 140
Exa 8.1 Magnitude and Phase Responses . . . . . . . . . . . . 143
Exa 8.2 Transfer Function of system . . . . . . . . . . . . . . . 146
Exa 8.3 Magnitude and Phase Responses . . . . . . . . . . . . 146
Exa 8.4 system response . . . . . . . . . . . . . . . . . . . . . 149
Exa 8.5 System function . . . . . . . . . . . . . . . . . . . . . 151
Exa 8.8 Transfer function . . . . . . . . . . . . . . . . . . . . . 153
Exa 8.9 Transfer function by block diagram reduction . . . . . 155
Exa 8.10 Realization Structure . . . . . . . . . . . . . . . . . . 155
Exa 8.12 Transfer function Realization . . . . . . . . . . . . . . 156
Exa 8.13 Parallel form realization . . . . . . . . . . . . . . . . . 157
Exa 9.1 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 158
Exa 9.3 Convolution . . . . . . . . . . . . . . . . . . . . . . . . 160
Exa 9.4 Autocorrelation . . . . . . . . . . . . . . . . . . . . . . 161
Exa 9.5 Autocorrelation . . . . . . . . . . . . . . . . . . . . . . 163
Exa 9.6 Autocorrelation . . . . . . . . . . . . . . . . . . . . . . 165
Exa 9.7 Autocorrelation . . . . . . . . . . . . . . . . . . . . . . 168
Exa 9.10 Autocorrelation Function . . . . . . . . . . . . . . . . 171
Exa 9.11 PSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Exa 10.1 Cross Correlation . . . . . . . . . . . . . . . . . . . . . 174
Exa 10.2 Cross Correlation Sequence . . . . . . . . . . . . . . . 176
Exa 10.4 Auto Correlation . . . . . . . . . . . . . . . . . . . . . 178
6
Exa 10.5 Auto Correlation . . . . . . . . . . . . . . . . . . . . . 178
Exa 10.8 Auto Correlation . . . . . . . . . . . . . . . . . . . . . 180
Exa 10.11 System response . . . . . . . . . . . . . . . . . . . . . 181
Exa 11.1 Hilbert Transform . . . . . . . . . . . . . . . . . . . . 184
Exa 11.2 Hilbert Transform . . . . . . . . . . . . . . . . . . . . 187
Exa 11.3 Hilbert Transform . . . . . . . . . . . . . . . . . . . . 189
Exa 11.6 Hilbert Transform . . . . . . . . . . . . . . . . . . . . 192
7
List of Figures
8
4.2 Magnitude and Phase Spectra . . . . . . . . . . . . . . . . . 58
4.3 Magnitude and Phase Spectra . . . . . . . . . . . . . . . . . 60
4.4 Magnitude and Phase Spectra . . . . . . . . . . . . . . . . . 61
4.5 Magnitude and Phase Spectra . . . . . . . . . . . . . . . . . 63
4.6 Magnitude and Phase Spectra . . . . . . . . . . . . . . . . . 64
4.7 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 67
4.8 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 68
4.9 Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.10 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 73
4.11 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 74
4.12 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 76
4.13 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . 77
5.1 DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.2 DTFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5.3 DTFT and Spectra . . . . . . . . . . . . . . . . . . . . . . . 84
5.4 DTFT and Spectra . . . . . . . . . . . . . . . . . . . . . . . 85
5.5 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.6 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.7 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.8 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 91
5.9 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 96
5.10 Inverse Fourier . . . . . . . . . . . . . . . . . . . . . . . . . 97
9
7.8 Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
7.9 Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.10 Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . 138
7.11 Step response . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.12 Magnitude and Phase Response . . . . . . . . . . . . . . . . 141
7.13 Magnitude and Phase Response . . . . . . . . . . . . . . . . 142
10
11.7 Hilbert Transform . . . . . . . . . . . . . . . . . . . . . . . . 193
11.8 Hilbert Transform . . . . . . . . . . . . . . . . . . . . . . . . 194
11
Chapter 1
12
Figure 1.1: Finding Fundamental Period
13
Figure 1.2: Finding Fundamental Period
14
5 clc ;
6 clear ;
7 syms t ;
8 x =3* cos (0.4* %pi * t ) +2* sin (0.66* t ) ;
9 disp (x , x ( t ) ) ;
10 t =0:1/50:50;
11 x =3* cos (0.4* %pi * t ) +2* sin (0.66* t ) ;
12 t =0:1/50:50;
13 plot (t , x ) ;
14 title ( x ( t ) ) ;
15 xlabel ( Time i n s e c o n d s ) ;
16 disp ( p l o t t e d t h e s i g n a l and shown t h a t i t i s not
p e r i o d i c and i s i n c r e a s i n g ) ;
15
Figure 1.3: Periodicity
16
Figure 1.4: Periodicity and fundamental period
17
4 // x ( t )=c o s ( 7 t )+s i n ( 4 t )
5 clc ;
6 clear ;
7 syms t ;
8 x = sin (4* t ) + cos (7* t ) ;
9 disp (x , x ( t ) ) ;
10 t =0:1/12:12
11 x = sin (4* t ) + cos (7* t ) ;
12 t =0:1/12:12;
13 plot (t , x ) ;
14 title ( x ( t ) ) ;
15 xlabel ( Time i n s e c o n d s ) ;
16 disp ( p l o t t e d t h e s i g n a l and shown t h a t i t is
p e r i o d i c with p e r i o d o f 2 p i );
18
Figure 1.5: Fundamental Period
19
Figure 1.6: Fundamental Period
15 title ( x ( t ) ) ;
16 xlabel ( Time i n s e c o n d s ) ;
17 disp ( p l o t t e d t h e s i g n a l and shown t h a t i t i s not
p e r i o d i c );
20
not
4 clc ;
5 clear ;
6
7 n =0:1:10;
8 x ( n +1) =2* sin (0.8* %pi * n ) ;
9 a = gca () ;
10 a . x_location = o r i g i n ;
11 a . y_location = o r i g i n ;
12 n =0:1:10;
13 plot2d3 (n ,x ,9) ;
14 title ( x ( n ) ) ;
15 disp ( p l o t i n g t h e s i g n a l and s h o w i n g t h a t i t is
p e r i o d i c with p e r i o d o f 5 );
21
Figure 1.7: Fundamental Period
22
16 plot (t , y1 ) ;
17 title ( y1 ( t ) ) ;
18 xlabel ( Time i n s e c o n d s ) ;
19 n =1;
20 for t = -1:0.01:1;
21 // F u n c t i o n f o r Odd s i g n a l
22 y2 ( n ) =0.5*( exp ( - t ) * u ( t ) - exp ( t ) * u ( - t ) ) ;
23 n = n +1;
24 end
25 figure (1) ;
26 a = gca () ;
27 a . x_location = o r i g i n ;
28 a . y_location = o r i g i n ;
29 t = -1:0.01:1;
30 // P l o t o f Odd S i g n a l
31 plot (t , y2 )
32 disp ( p l o t t e d t h e s i g n a l b o t h i n e v e n and odd f o r m s
);
33 title ( y2 ( t ) ) ;
34 xlabel ( Time i n s e c o n d s ) ;
23
Figure 1.8: Even and odd Components
24
Figure 1.9: Even and odd Components
25
-1) + abs (t -3) * u (t -3) ;
8 end
9 t = -3:1:3;
10 // f o r t h e main g i v e n s i g n a l
11 a = gca () ;
12 a . x_location = o r i g i n ;
13 a . y_location = o r i g i n ;
14 plot (t , y ) ;
15 title ( Main S i g n a l ) ) ;
16 dy =0* y ;
17 for i =1:6
18 dy ( i ) =( y ( i +1) -y ( i ) ) /1;
19 end
20 // f o r t h e d e r i v a t i v e o f t h e g i v e n s i g n a l
21 figure (1) ;
22 a = gca () ;
23 a . x_location = o r i g i n ;
24 a . y_location = o r i g i n ;
25 plot2d2 (t , dy ) ;
26 title ( D e r i v a t i v e o f S i g n a l ) ;
27 dy2 =0* dy ;
28 dy2 (1) = dy (1) -0;
29 for i =1:6
30 dy2 ( i +1) =( dy ( i +1) - dy ( i ) ) /1;
31 end
32 // f o r t h e i m p u l s e r e s p o n s e r e p r e s e n t a t i o n o r s e c o n d
derivative
33 figure (2) ;
34 a = gca () ;
35 a . x_location = o r i g i n ;
36 a . y_location = o r i g i n ;
37 plot2d3 (t , dy2 , -5) ;
38 title ( I m p u l s e r e s p o n s e r e p r e s e n t a t i o n ) ;
26
Figure 1.10: Waveforms
27
Figure 1.11: Waveforms
28
Scilab code Exa 1.12 Time Scaling
29
Figure 1.12: Time Scaling
30
Figure 1.13: Time Scaling
31
1 // S c i l a b Code f o r Example 1 . 1 3 o f S i g n a l s and
s y s t e m s by
2 //P . Ramakrishna Rao
3 clc ;
4 clear ;
5 // D i s c r e t e t i m e s e q u e n c e p l o t
6 clc
7 A =10;
8 t =0:1/1000:1;
9 x = A * sin (2* %pi *100* t ) ;
10 q = plot2d3 (t , x ) ;
11 disp ( d i s p l a y i n g a f u n c t i o n p l o t on d i s c r e t e t i m e
s c a l e t h a t has a sampling f r e q u e n c y o f 1000
samples ps );
32
Figure 1.14: Plot at a particular sampling frequency
33
Chapter 2
34
2 //P . Ramakrishna Rao
3 // I n v e r s e L a p l a c e T r a n s f o r m
4 clc ;
5 clear ;
6 syms t s
7 X =( s +2) /( s ^2+8* s +25)
8 f4 = ilaplace ( X ) ;
9 disp ( f4 * u ( t ) , x ( t )= ) ;
10 // t >=0
35
Scilab code Exa 2.4 Laplace Transform
36
1 // S c i l a b Code f o r Example 2 . 7 o f S i g n a l s and s y s t e m s
by
2 //P . Ramakrishna Rao
3 // U n i l a t e r a l L a p l a c e T r a n s f o r m u s i n g p a r t i a l
fraction
4 clear ;
5 clc ;
6 syms t s ;
7 s = %s ;
8 a1 = pfss (( s +3) /( s ^2+3* s +2) )
9 f1 = ilaplace ( a1 (1) )
10 f2 = ilaplace ( a1 (2) )
11 fy = f1 + f2
12 disp ( fy * u ( t ) , i ) f ( t )= )
13 a2 = pfss ((2* s -1) /( s ^2+2* s +1) )
14 a2 (1) =2/( s +1)
15 a2 (2) = -3/( s +1) ^2
16 f1 = ilaplace ( a2 (1) )
17 f2 = ilaplace ( a2 (2) )
18 fz = f1 + f2
19 disp ( fz * u ( t ) , i i ) f ( t )= )
37
Scilab code Exa 2.9 Circuit Current
38
Figure 2.1: Laplace Transform
39
8 disp (y , X( s )= ) ;
9 disp ( Re ( s )>3 ) ;
10 y =5/( s +3) ;
11 plzr ( y ) ;
40
Figure 2.2: Laplace Transform
41
Figure 2.3: Laplace Transform
42
Figure 2.4: Laplace Transform
6 s = %s ;
7 y = laplace ( exp ( - t ) - exp (2* t ) ,t , s ) ;
8 disp (y , X( s )= ) ;
9 y =(1/( s +1) ) -(1/( s -2) ) ;
10 plzr ( y ) ;
43
3 //Z t r a n s f o r m o f a n u ( n )
4 clear ;
5 clc ;
6 close ;
7 syms a n z ;
8 x1 =1/2;
9 x2 =1/3;
10 X1 = symsum ( x1 *( z ^( - n ) ) ,n ,0 , %inf ) ;
11 X2 = symsum ( x2 *( z ^( - n ) ) ,n ,0 , %inf ) ;
12 X = X1 + X2 ;
13 // D i s p l a y t h e r e s u l t
14 disp (X , Zt r a n s f o r m o f u ( n ) i s : ) ;
15 disp ( ROC i s t h e R e g i o n | z |> 1/2 ) ;
44
1 // S c i l a b Code f o r Example 2 . 3 7 o f S i g n a l s and
s y s t e m s by
2 //P . Ramakrishna Rao
3 // I n v e r s e Z T r a n s f o r m :ROC 1 <| z | <2
4 clear ;
5 clc ;
6 z = %z ;
7 syms n z1 ;
8 //To f i n d o u t I n v e r s e z t r a n s f o r m z must be l i n e a r z
= z1
9 X =( z *( z ^2 - z +1) ) /(( z -0.5) *( z -2) *( z -1) )
10 X1 = denom ( X ) ;
11 zp = roots ( X1 ) ;
12 X1 = ( z1 *( z1 ^2 - z1 +1) ) /(( z1 -0.5) *( z1 -2) *( z1 -1) )
13 F1 = X1 *( z1 ^( n -1) ) *( z1 - zp (1) )
14 F2 = X1 *( z1 ^( n -1) ) *( z1 - zp (2) )
15 F3 = X1 *( z1 ^( n -1) ) *( z1 - zp (3) )
16 h1 = limit ( F1 , z1 , zp (1) ) ;
17 disp ( h1 * u(n 1) , h1 [ n ]= )
18 h2 = limit ( F2 , z1 , zp (2) ) ;
19 disp (( h2 ) * u ( n ) , h2 [ n ]= )
20 h3 = limit ( F3 , z1 , zp (3) ) ;
21 disp (( h3 ) * u ( n ) , h3 [ n ]= )
22 disp (( h3 ) * u ( n ) +( h2 ) * u ( n ) -( h1 ) * u(n 1) , h [ n ]= )
23 // // R e s u l t
24 // h [ n ]=1 0 . 5 n u ( n ) 2 u ( n ) 2 2 n u( n
1)
45
5 clc ;
6 z = %z ;
7 syms n z1 ;
8 //To f i n d o u t I n v e r s e z t r a n s f o r m z must be l i n e a r z
= z1
9 X = z ^2/( z ^2+3* z +2) ;
10 X1 = denom ( X ) ;
11 zp = roots ( X1 )
12 X1 = z1 ^2/( z1 ^2+3* z1 +2) ;
13 F1 = X1 *( z1 ^( n -1) ) *( z1 - zp (1) ) ;
14 F2 = X1 *( z1 ^( n -1) ) *( z1 - zp (2) ) ;
15 h1 = limit ( F1 , z1 , zp (1) ) ;
16 disp ( h1 * u ( n ) , h1 [ n ]= )
17 h2 = limit ( F2 , z1 , zp (2) ) ;
18 disp (( h2 ) * u ( n ) , h2 [ n ]= ) ;
19 disp (( h1 ) * u ( n ) +( h2 ) * u ( n ) , h [ n ]= ) ;
20 // // R e s u l t
21 // h [ n ]= (2( 2 ) n+1 ( 1 ) n ) u ( n )
46
13 F1 = X1 *( z1 ^( n ) ) *( z1 - zp (1) ) ;
14 h1 = limit ( F1 , z1 , zp (1) )
15 disp ( -( h1 ) * u(n 1) , h [ n ]= ) ;
16 // // R e s u l t
17 // h [ n ]= ( ( 4 ) n ) u(n 1)
47
3 // I n v e r s e Z T r a n s f o r m :ROC | z | >2
4 clear ;
5 clc ;
6 z = %z ;
7 syms n z1 ;
8 //To f i n d o u t I n v e r s e z t r a n s f o r m z must be l i n e a r z
= z1
9 X = z ^2/(( z -0.5) *( z -1) ) ;
10 X1 = denom ( X ) ;
11 zp = roots ( X1 )
12 X1 = z1 ^2/(( z1 -0.5) *( z1 -1) ) ;
13 F1 = X1 *( z1 ^( n -1) ) *( z1 - zp (1) ) ;
14 F2 = X1 *( z1 ^( n -1) ) *( z1 - zp (2) ) ;
15 h1 = limit ( F1 , z1 , zp (1) ) ;
16 disp ( h1 * u ( n ) , h1 [ n ]= )
17 h2 = limit ( F2 , z1 , zp (2) ) ;
18 disp (( h2 ) * u ( n ) , h2 [ n ]= ) ;
19 disp ( -( h1 ) * u(n 1) -( h2 ) * u(n 1) , h [ n ]= ) ;
20 // // R e s u l t
21 // h [ n ]= ( ( 0 . 5 ) n 2 ) u(n 1)
48
Chapter 3
49
Figure 3.1: Complex Fourier Exponential Series
50
Figure 3.2: Complex Fourier Exponential Series
51
15 x =[ x - ones (1 , length ( t_temp ) ) * %pi ];
16 else
17 x =[ x ones (1 , length ( t_temp ) ) * %pi ];
18 end
19 end
20 figure (1) ;
21 title ( S i g n a l ) ;
22 ylabel ( x ( t ) ) ;
23 xlabel ( t ) ;
24 plot (t ,x , r )
25 w0 = %pi /2;
26 for k = -10:10
27 cc ( k +11 ,:) = exp ( - %i * k * w0 * t ) ;
28 ck ( k +11) = x * cc ( k +11 ,:) / length ( t ) ;
29 if abs ( ck ( k +11) ) <0.01 then
30 ck ( k +11) =0;
31 else if real ( ck ( k +11) ) <0.1 then
32 ck ( k +11) = %i * imag ( ck ( k +11) ) ;
33 end
34 end
35 if k ==0 then
36 c0 = ck ( k +11) ;
37 end
38 end
39 q = abs ( ck ) ;
40 figure (2) ;
41 title ( Magnitude Spectrum ) ;
42 ylabel ( | cn | ) ;
43 xlabel ( f o ) ;
44 f = -10:1:10;
45 plot2d3 (f , q )
52
Figure 3.3: Complex Fourier Exponential Series
53
Figure 3.4: Complex Fourier Exponential Series
54
Scilab code Exa 3.14 Complex Fourier Exponential Series
55
Figure 3.5: Complex Fourier Exponential Series
36 c = gca () ;
37 c . y_location = o r i g i n ;
38 c . x_location = o r i g i n ;
39 plot2d3 ( gnn ,k , abs ( ck ) ,9)
40 poly1 = c . children (1) . children (1) ;
41 poly1 . thickness = 3;
42 title ( | ck | )
43 xlabel ( k )
56
1 // S c i l a b Code f o r Example 3 . 1 6 o f S i g n a l s and
s y s t e m s by
2 //P . Ramakrishna Rao
3 //A=%pi o r 3 . 1 4
4 clear ;
5 clc ;
6 // T r i g n o m e t r i c F o u r i e r C o e f f i c i e n t s
7 for n =0:5
8 a ( n +1) = integrate ( t c o s ( 2 %pi n t ) , t ,0 ,1) ;
9 end
10 for n =0:5
11 b ( n +1) = integrate ( t s i n ( 2 %pi n t ) , t ,0 ,1) ;
12 end
13 disp ( %pi * a (1) , an ( a0 ) )
14 disp ( an ( a1>a5 ) )
15 for n =1:5
16 disp (2* a ( n +1) * %pi )
17 end
18 disp ( bn ( b1>b5 ) )
19 for n =1:5
20 disp (2* %pi * b ( n +1) )
21 end
22 //CTFS c o e f f i c i e n t s o f a p e r i o d i c s i g n a l
23 // x ( t ) =t
24 t = 0:0.01:1;
25 xt =2* %pi * t ;
26 //
27 for k =0:6
28 C ( k +1 ,:) = exp ( - sqrt ( -1) *2* %pi * t * k ) ;
29 c ( k +1) = xt * C ( k +1 ,:) / length ( t ) ;
30 if ( abs ( c ( k +1) ) <=0.01)
31 c ( k +1) =0;
32 end
33 end
34 c =c ;
35 c_conj = real ( c (:) ) - sqrt ( -1) * imag ( c (:) ) ;
36 ck = [ c_conj ( $ : -1:1) ,c (2: $ ) ];
37 k = 0:6;
57
Figure 3.6: Complex Fourier Exponential Series
38 k = [ - k ( $ : -1:1) ,k (2: $ ) ];
39 c = gca () ;
40 c . y_location = o r i g i n ;
41 c . x_location = o r i g i n ;
42 plot2d3 ( gnn ,k , abs ( ck ) )
43 poly1 = c . children (1) . children (1) ;
44 poly1 . thickness = 3;
45 title ( | ck | )
46 xlabel ( k )
58
Figure 3.7: Complex Fourier Exponential Series
59
Scilab code Exa 3.17 Complex Fourier Exponential Series
60
36 figure (1) ;
37 c = gca () ;
38 c . y_location = o r i g i n ;
39 c . x_location = o r i g i n ;
40 plot2d3 ( gnn ,k , abs ( ck ) )
41 poly1 = c . children (1) . children (1) ;
42 poly1 . thickness = 3;
43 title ( | ck | )
44 xlabel ( k )
61
Chapter 4
62
Figure 4.1: Magnitude and Phase Spectra
63
Figure 4.2: Magnitude and Phase Spectra
64
15 end
16 end
17 Wmax = 2* %pi *1; // Analog F r e q u e n c y = 1Hz
18 K = 4;
19 k = 0:( K /1000) : K ;
20 W = k * Wmax / K ;
21 xt = xt ;
22 XW = xt * exp ( - sqrt ( -1) *t * W ) * Dt ;
23 XW_Mag = real ( XW ) ;
24 W = [ - mtlb_fliplr ( W ) , W (2:1001) ]; // Omega from
Wmax t o Wmax
25 XW_Mag = [ mtlb_fliplr ( XW_Mag ) , XW_Mag (2:1001) ];
26 [ XW_Phase , db ] = phasemag ( XW ) ;
27 XW_Phase =[ - mtlb_fliplr ( XW_Phase ) , XW_Phase (2:1001) ];
28 // P l o t t i n g t h e F u n c t i o n
29 subplot (2 ,1 ,1) ;
30 a = gca () ;
31 a . data_bounds =[ -4 ,0;4 ,2];
32 a . y_location = o r i g i n ;
33 plot (t , xt ) ;
34 xlabel ( t i n s e c . ) ;
35 title ( C o n t i n o u s Time S i g n a l x ( t ) ) ;
36 // P l o t t i n g Magnitude Reponse o f CTS
37 subplot (2 ,1 ,2) ;
38 a = gca () ;
39 a . y_location = o r i g i n ;
40 plot ( W /(2* %pi ) , XW_Mag ) ;
41 xlabel ( F r e q u e n c y i n Hz ) ;
42 title ( C o n t i n u o u s t i m e F o u r i e r T r a n s f o r m X(jW) ) ;
43 // P l o t t i n g Phase Reponse o f CTS
44 figure (1) ;
45 a = gca () ;
46 a . y_location = o r i g i n ;
47 a . x_location = o r i g i n ;
48 plot ( W /(2* %pi ) ,- XW_Phase * %pi /180) ;
49 xlabel ( F r e q u e n c y i n Hz ) ;
50 ylabel ( <X(jW) )
51 title ( Phase R e s p o n s e (CTFT) i n R a d i a n s )
65
Figure 4.3: Magnitude and Phase Spectra
66
Figure 4.4: Magnitude and Phase Spectra
67
6 clc ;
7 close ;
8 // Analog S i g n a l
9 A =1; // A m p l i t u d e
10 T =1;
11 Dt = 0.005;
12 t = 0: Dt :10;
13 xt = A * exp ( - t / T ) ;
14 // C o n t i n u o u s t i m e F o u r i e r T r a n s f o r m
15 Wmax = 2* %pi *1; // Analog F r e q u e n c y = 1Hz
16 K = 4;
17 k = 0:( K /1000) : K ;
18 W = k * Wmax / K ;
19 XW = xt * exp ( - sqrt ( -1) *t * W ) * Dt ;
20 XW_Mag = abs ( XW ) ;
21 W = [ - mtlb_fliplr ( W ) , W (2:1001) ]; // Omega from
Wmax t o Wmax
22 XW_Mag = [ mtlb_fliplr ( XW_Mag ) , XW_Mag (2:1001) ];
23 [ XW_Phase , db ] = phasemag ( XW ) ;
24 XW_Phase = [ - mtlb_fliplr ( XW_Phase ) , XW_Phase (2:1001)
];
25 // P l o t t i n g C o n t i n u o u s Time S i g n a l
26 a = gca () ;
27 a . y_location = o r i g i n ;
28 plot (t , xt ) ;
29 xlabel ( t i n s e c . ) ;
30 ylabel ( x ( t ) )
31 title ( C o n t i n u o u s Time S i g n a l )
32 figure
33 // P l o t t i n g Magnitude R e s p o n s e o f CTS
34 subplot (2 ,1 ,1) ;
35 a = gca () ;
36 a . y_location = o r i g i n ;
37 plot (W , XW_Mag ) ;
38 xlabel ( F r e q u e n c y i n R a d i a n s / S e c o n d s > W ) ;
39 ylabel ( a b s (X(jW) ) )
40 title ( Magnitude R e s p o n s e (CTFT) )
41 // P l o t t i n g Phase Reponse o f CTS
68
Figure 4.5: Magnitude and Phase Spectra
42 subplot (2 ,1 ,2) ;
43 a = gca () ;
44 a . y_location = o r i g i n ;
45 a . x_location = o r i g i n ;
46 plot (W , XW_Phase * %pi /180) ;
47 xlabel ( Frequency in
R a d i a n s / S e c o n d s > W ) ;
48 ylabel (
<X
(jW) )
49 title ( Phase R e s p o n s e (CTFT) i n R a d i a n s )
69
Figure 4.6: Magnitude and Phase Spectra
70
Scilab code Exa 4.3 Magnitude and Phase Spectra
71
31 xlabel ( F r e q u e n c y i n Hz ) ;
32 title ( C o n t i n u o u s Time F o u r i e r T r a n s f o r m X(jW) ) ;
72
Figure 4.7: Fourier Transform
73
Figure 4.8: Fourier Transform
74
3 // x ( t )=c o s p i t , | t | > 0 . 5 , z e r o o t h e r w i s e
4 clear ;
5 clc ;
6 // F o u r i e r T r a n s f o r m
7 for f = -20:1:20;
8 X ( f +21) = integrate ( c o s ( %pi t ) c o s ( 2 %pi f t ) , t
, -0.5 ,0.5) ;
9 end
10 disp (X , X( 0 )>X( 2 0 ) ) ;
11 t = -0.5:0.01:0.5;
12 q = cos ( %pi * t ) ;
13 a = gca () ;
14 a . y_location = o r i g i n ;
15 a . x_location = o r i g i n ;
16 plot (t , q ) ;
17 xlabel ( Time i n S e c o n d s ) ;
18 title ( S i g n a l x ( t ) ) ;
19 figure (1) ;
20 a = gca () ;
21 a . y_location = o r i g i n ;
22 a . x_location = o r i g i n ;
23 f = -20:1:20;
24 plot (f , X ) ;
25 xlabel ( F r e q u e n c y i n Hz ) ;
26 title ( C o n t i n u o u s Time F o u r i e r T r a n s f o r m X(jW) ) ;
75
Figure 4.9: Convolution
76
5 close ;
6 disp ( X(w) =1/( a+jw ) 2=1/( a+jw ) 1 / ( a+jw ) ) ;
7 disp ( exp (a t ) u ( t ) <> 1 / ( a+jw ) ) ;
8 disp ( t h e r e f o r e x ( t )=c o n v o l u t i o n ( 2 s i n c ( 2 t ) , ( s i n c t
) 2 ) ;
9 a =2;
10 n =1;
11 for t = -10:0.1:10
12 y1 (1 , n ) =( sinc ( t ) ) ^2;
13 y2 (1 , n ) =2* sinc (2* t ) ;
14 n = n +1;
15 z = conv ( y1 , y2 ) ;
16 end
17 t = -20:0.1:20;
18 a = gca () ;
19 a . y_location = o r i g i n ;
20 a . x_location = o r i g i n ;
21 plot (t , z ) ;
22 title ( C o n v o l u t i o n o f x ( t ) and y ( t ) )
77
Scilab code Exa 4.11 Fourier Transform
78
Figure 4.10: Fourier Transform
79
Figure 4.11: Fourier Transform
80
10 disp ( G u a s s i a n p u l s e s i g n a l x ( t ) =(1/ s q r t ( 2 ) %pi ) exp
(a t 2 ) ) ;
11 disp ( X(w)= i n t e g r a l ( exp (a t 2 ) exp (%i w t ) ) w . r . t
dt );
12 disp ( d (X(w) ) /dw=%i w/ ( 2 a ) i n t e g r a l ( exp (a t 2 )
exp (%i w t ) ) ) ;
13 disp ( d (X(w) ) /dw=wX(w) /2 a ) ;
14 disp ( s o l v i n g t h i s we g e t X(w)=A exp (w 2 / 4 a ) )
15 disp ( A=s q r t ( %pi / a ) ) ;
16 d = gca ()
17 plot (t , x ) ;
18 poly1 = d . children . children ;
19 poly1 . thickness =3;
20 poly1 . foreground =2;
21 xtitle ( x ( t ) , t )
22 A =1;
23 f=t;
24 Xf = A * exp ( -2* %pi ^2* f ^2) ;
25 figure (1) ;
26 d = gca ()
27 plot (f , Xf ) ;
28 poly1 = d . children . children ;
29 poly1 . thickness =3;
30 poly1 . foreground =2;
31 xtitle ( X( f ) , f )
81
Figure 4.12: Fourier Transform
82
Figure 4.13: Fourier Transform
83
3 clear ;
4 clc ;
5 // F o u r i e r T r a n s f o r m o f x ( t )
6 n =1;
7 for t = -10:0.1:10;
8 x (1 , n ) =1/(1+ t ^2) ;
9 n = n +1;
10 end
11 a = gca () ;
12 a . y_location = o r i g i n ;
13 a . x_location = o r i g i n ;
14 t = -10:0.1:10;
15 plot (t , x ) ;
16 xlabel ( Time i n S e c o n d ) ;
17 title ( x ( t ) ) ;
18 disp ( By D u a l i t y Theorem F o u r i e r T r a n s f o r m o f x ( t )
i s : );
19 disp ( %pi exp ( |w | ) ) ;
20 n =1;
21 for w = -10:0.1:10;
22 X (1 , n ) = %pi * exp ( - abs ( w ) ) ;
23 n = n +1;
24 end
25 figure (1) ;
26 a = gca () ;
27 a . y_location = o r i g i n ;
28 a . x_location = o r i g i n ;
29 w = -10:0.1:10;
30 plot (w , X ) ;
31 xlabel ( F r e q u e n c y i n R a d i a n s / S e c o n d ) ;
32 title ( X(w) ) ;
84
Chapter 5
Fourier Representation of
Discrete Time Signals
85
19 XW_Mag = real ( XW ) ;
20 W = [ - mtlb_fliplr ( W ) , W (2:1001) ]; // Omega from
Wmax t o Wmax
21 XW_Mag = [ mtlb_fliplr ( XW_Mag ) , XW_Mag (2:1001) ];
22 a = gca () ;
23 a . y_location = o r i g i n ;
24 a . x_location = o r i g i n ;
25 plot2d3 ( gnn ,n , x ) ;
26 xtitle ( D i s c r e t e Time S e q u e n c e x [ n ] f o r a>0 )
27 figure (1) ;
28 a = gca () ;
29 a . y_location = o r i g i n ;
30 a . x_location = o r i g i n ;
31 plot2d (W , XW_Mag ) ;
32 title ( D i s c r e t e Time F o u r i e r T r a n s f o r m X( exp (jW) ) )
86
Figure 5.1: DTFT
87
Figure 5.2: DTFT
88
13 Wmax = 2* %pi ;
14 K = 4;
15 k = 0:( K /1000) : K ;
16 W = k * Wmax / K ;
17 XW = x * exp ( - sqrt ( -1) *n * W ) ;
18 XW_Mag = real ( XW ) ;
19 [ XW_Phase , db ] = phasemag ( XW ) ;
20 W = [ - mtlb_fliplr ( W ) , W (2:1001) ]; // Omega from
Wmax t o Wmax
21 XW_Mag = [ mtlb_fliplr ( XW_Mag ) , XW_Mag (2:1001) ];
22 XW_Phase = [ - mtlb_fliplr ( XW_Phase ) , XW_Phase (2:1001)
];
23 a = gca () ;
24 a . y_location = o r i g i n ;
25 a . x_location = o r i g i n ;
26 plot2d3 ( gnn ,n , x ) ;
27 xtitle ( D i s c r e t e Time S e q u e n c e x [ n ] )
28 figure (1) ;
29 a = gca () ;
30 a . y_location = o r i g i n ;
31 a . x_location = o r i g i n ;
32 plot2d (W , abs ( XW_Mag ) ) ;
33 title ( D i s c r e t e Time F o u r i e r T r a n s f o r m X( exp (jW) ) )
34 figure (2) ;
35 a = gca () ;
36 a . y_location = o r i g i n ;
37 a . x_location = o r i g i n ;
38 plot2d (W , XW_Phase ) ;
39 title ( Phase R e s p o n s e <(X(jW) ) )
89
Figure 5.3: DTFT and Spectra
90
Figure 5.4: DTFT and Spectra
91
1 // S c i l a b Code f o r Example 5 . 3 o f S i g n a l s and s y s t e m s
by
2 //P . Ramakrishna Rao
3 clear ;
4 clc ;
5 // I n v e r s e F o u r i e r T r a n s f o r m
6 w = -20:20;
7 X =4*( cos ( w ) ) ^2;
8 a = gca () ;
9 a . y_location = o r i g i n ;
10 a . x_location = o r i g i n ;
11 plot (w , X ) ;
12 title ( X( e jw ) ) ;
13 xlabel ( F r e q u e n c y i n R a d i a n s / s e c ) ;
14 figure (1) ;
15 n = -50:50;
16 x =2* sinc ( n ) + sinc ( n +2) + sinc (n -2) ;
17 a = gca () ;
18 a . y_location = o r i g i n ;
19 a . x_location = o r i g i n ;
20 plot2d3 (n , x ) ;
21 title ( x ( n ) ) ;
22 xlabel ( Time i n s e c ) ;
92
Figure 5.5: Inverse Fourier
93
Figure 5.6: Inverse Fourier
94
5 clear ;
6 clc ;
7 close ;
8 N = 1;
9 N1 = -3* N :3* N ;
10 xn = [ zeros (1 ,N -1) ,1];
11 x = [1 xn xn xn xn xn xn ];
12 ak = 1/ N ;
13 XW = 2* %pi * ak * ones (1 ,2* N ) ;
14 Wo = 2* %pi / N ;
15 n = -N :N -1;
16 W = Wo * n ;
17 a = gca () ;
18 a . y_location = m i d d l e ;
19 a . x_location = o r i g i n ;
20 plot2d3 ( gnn ,W , XW ,2) ;
21 poly1 = a . children (1) . children (1) ;
22 poly1 . thickness = 3;
23 xlabel ( W ) ;
24 title ( DTFT o f P e r i o d i c I m p u l s e T r a i n )
25 figure (1) ;
26 a = gca () ;
27 a . y_location = o r i g i n ;
28 a . x_location = o r i g i n ;
29 plot2d3 ( gnn ,N1 ,x ,2) ;
30 poly1 = a . children (1) . children (1) ;
31 poly1 . thickness = 3;
32 xlabel ( n ) ;
33 title ( P e r i o d i c I m p u l s e T r a i n x ( n ) )
95
Figure 5.7: Inverse Fourier
96
Figure 5.8: Inverse Fourier
97
1 // S c i l a b Code f o r Example 5 . 5 o f S i g n a l s and s y s t e m s
by
2 //P . Ramakrishna Rao
3 clear ;
4 clc ;
5 x =[1 ,2 ,3 ,2 ,1];
6 q =0;
7 for n =1:5
8 q=x(n)+q;
9 end
10 disp (q , ( a ) X( e j 0 ) ) ;
11 q =0;
12 for n = -2:2
13 q =(( -1) ^ n ) * x ( n +3) + q ;
14 end
15 disp (q , ( c ) X( e j p i ) ) ;
16 disp ( ( d ) X( e j p i ) =2 p i x ( 0 ) ) ;
17 disp (2* %pi * x (3) ) ;
18 q =0;
19 for n = -2:2
20 q =( x ( n +3) ) ^2+ q ;
21 end
22 disp ( q *2* %pi , ( e ) | X( e j w) | 2 ) ;
98
9 x1 = a1 ^ n ;
10 x2 = a2 ^ n ;
11 w =2;
12 n =0:100;
13 z =( exp ( - %i * w * n ) ) ;
14 for n =0:33;
15 X ( n +1) = z ( n +1) * x1 (3* n +1) ;
16 q = X ( n +1) + q ;
17 end
18 disp (q , Y1 ( e 2 j ) a t a =0.5 ) ;
19 for n =0:33;
20 X ( n +1) = z ( n +1) * x2 (3* n +1) ;
21 q = X ( n +1) + q ;
22 end
23 disp (q , Y1 ( e 2 j ) a t a =0.5 ) ;
99
17 end
18 disp (q , Y2 ( e 2 j ) a t a =0.5 ) ;
19 for n =0:33;
20 X ( n +1) = z ( n +1) * x2 ( n +1) ;
21 q = X ( n +1) + q ;
22 end
23 disp (q , Y2 ( e 2 j ) a t a =0.5 ) ;
100
Scilab code Exa 5.11 Inverse Fourier
101
Figure 5.9: Inverse Fourier
32 xlabel ( Time i n S e c o n d s ) ;
33 title ( x ( n ) at Wc=1 ) ;
102
Figure 5.10: Inverse Fourier
103
4 clear ;
5 // F i r s t C a u s a l s e q u e n c e
6 x =[1 ,4 ,3 ,2;2 ,1 ,4 ,3;3 ,2 ,1 ,4;4 ,3 ,2 ,1]
7 // S e c o n d S e q u e n c e
8 y =[4;3;2;1]
9 // C o n o l u t i o n
10 z = x * y ;
11 disp (z , C o n v o l u t i o n Of x & y i s : )
104
Scilab code Exa 5.16 DTFT
105
32 disp ( ceil ( q ) , X( 2 )>s e c o n d DFT c o e f f i c i e n t ) ;
33 q =0;
34 w =3* %pi /2;
35 n =0:3;
36 z =( exp ( - %i * w * n ) ) ;
37 for n =0:3
38 X ( n +1) = z ( n +1) * x ( n +1) ;
39 q = X ( n +1) + q ;
40 end
41 disp (q , X( 3 )> t h i r d DFT c o e f f i c i e n t ) ;
106
Chapter 6
107
* fs +75) ];
19 end
20 n = n +1;
21 for f = -275:275
22 X_delta2 ( f +276) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
23 end
24 n = n +1;
25 for f = -275:275
26 X_delta3 ( f +276) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
27 end
28 X_delta = X_delta1 + X_delta2 + X_delta3 ;
29 figure (2) ;
30 f = -275:275;
31 plot2d3 (f , X_delta , -2) ;
32 title ( X d e l t a ( f ) a t f s =200 ) ;
33 xlabel ( > f ) ;
108
Figure 6.1: Sampling and Reconstruction
109
Figure 6.2: Sampling and Reconstruction
110
9 end
10 figure (1) ;
11 f = -200:200;
12 plot2d3 (f ,X , -2) ;
13 title ( X( f ) ) ;
14 xlabel ( > f ) ;
15 w =1;
16 n = -2;
17 for f = -175:175
18 X_delta1 ( f +176) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
19 end
20 n = n +1;
21 for f = -175:175
22 X_delta2 ( f +176) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
23 end
24 n = n +1;
25 for f = -175:175
26 X_delta3 ( f +176) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
27 end
28 n = n +1;
29 for f = -175:175
30 X_delta4 ( f +176) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
31 end
32 n = n +1;
33 for f = -175:175
34 X_delta5 ( f +176) = fs *5*[ delta (f - n * fs -75) + delta (f - n
* fs +75) ];
35 end
36 X_delta = X_delta1 + X_delta2 + X_delta3 + X_delta4 + X_delta5
;
37 figure (2) ;
38 f = -175:175;
39
40 plot2d3 (f , X_delta , -2) ;
111
Figure 6.3: Sampling and Reconstruction
41 title ( X d e l t a ( f ) a t f s =100 ) ;
42 xlabel ( > f ) ;
43 // The P r e s e n c e o f t h e 25 HZ component i n t h e
spectrum o f x d e l t a ( t )
44 // Due t o e f f e c t o f A l i a s i n g
112
Figure 6.4: Sampling and Reconstruction
113
by
2 //P . Ramakrishna Rao
3 // Minimum no . o f s a m p l e s r e q u i r e d
4 clc ;
5 clear ;
6 syms t ;
7 x =10* cos (6* %pi * t ) +4* sin (8* %pi * t ) ;
8 disp (x , x ( t ) ) ;
9 disp ( Maximum F r e q u e n c y component p r e s e n t : 4 Hz ) ;
10 fs =2*4;
11 disp ( fs , Minimum S a m p l i n g F r e q u e n c y t o a v o i d
d i s t o r t i o n i s : );
114
4 clear ;
5
6 for f = -100:100
7 X ( f +101) = delta ( f +100) + delta (f -100) +3*[ delta ( f
+90) + delta (f -90) ];
8 end
9 f = -100:100;
10 a = gca () ;
11 a . x_location = o r i g i n ;
12 a . y_location = o r i g i n ;
13 plot2d3 (f ,X , -2) ;
14 title ( Spectrum o f x ( t ) ) ;
15 xlabel ( > f ) ;
16 fs =150;
17 n = -1; f - n * fs
18 for f = -275:275
19 X_delta1 ( f +276) = delta (f - n * fs +100) + delta (f - n * fs
-100) +3*[ delta (f - n * fs +90) + delta (f - n * fs -90) ];
20 end
21 n = n +1;
22 for f = -275:275
23 X_delta2 ( f +276) = delta (f - n * fs +100) + delta (f - n * fs
-100) +3*[ delta (f - n * fs +90) + delta (f - n * fs -90) ];
24 end
25 n = n +1;
26 for f = -275:275
27 X_delta3 ( f +276) = delta (f - n * fs +100) + delta (f - n * fs
-100) +3*[ delta (f - n * fs +90) + delta (f - n * fs -90) ];
28 end
29 X_delta = X_delta1 + X_delta2 + X_delta3 ;
30 figure (2) ;
31 f = -275:275;
32 plot2d3 (f , X_delta , -2) ;
33 title ( X d e l t a ( f ) a t f s =150 ) ;
34 xlabel ( > f ) ;
115
Figure 6.5: LPF output
116
Figure 6.6: LPF output
117
6 syms t ;
7 x =12* cos (800* %pi * t ) * cos ((1800* %pi * t ) ) ^2;
8 disp (x , x ( t ) ) ;
9 disp ( Maximum F r e q u e n c y component p r e s e n t : 2 2 0 0 Hz )
;
10 fs =2*2200;
11 disp ( fs , Minimum S a m p l i n g F r e q u e n c y t o a v o i d
d i s t o r t i o n i s ( Hz ) : ) ;
118
Chapter 7
Systems
119
21 q (1 , t ) = a0 + a1 * x ( t ) + a2 *( x ( t ) ) ^2;
22 end
23 disp (q , T h i s i n p u t g i v e s t h e o u t p u t : ) ;
24 y = b1 * y1 + b2 * y2 ;
25 disp (y , For t h e s y s t e m t o be l i n e a r t h e o u t p u t
s h o u l d be : ) ;
26 disp ( Hence t h e s y s t e m i s n o t l i n e a r ) ;
120
24 disp (q , T h i s i n p u t g i v e s t h e o u t p u t : ) ;
25 disp (y , For t h e s y s t e m t o be l i n e a r t h e o u t p u t
s h o u l d be : ) ;
26 disp ( Hence t h e s y s t e m i s l i n e a r ) ;
121
27 disp ( For a d e l a y (T) o f 2 s e c o n d s ) ;
28 disp ( At t =3 s e c o n d s : ) ;
29 t =3;
30 a = x (1 ,2* t -2) ;
31 b = y (1 ,t -2) ;
32 c = x (1 ,2* t -4) ;
33 disp (a , x ( 2 tT) : ) ;
34 disp (b , i s n o t e q u a l t o y ( 2 tT) : ) ;
35 disp (c , w h i l e x ( 2 t 2T) : ) ;
36 disp ( Hence t h e s y s t e m i s Time v a r i a n t ) ;
122
22 end
23 disp (q , T h i s i n p u t g i v e s t h e o u t p u t : ) ;
24 y = b1 * y1 + b2 * y2 ;
25 disp (y , For t h e s y s t e m t o be l i n e a r t h e o u t p u t
s h o u l d be : ) ;
26 disp ( Hence t h e s y s t e m i s l i n e a r ) ;
27 disp ( For a d e l a y ( n0 ) o f 2 s e c o n d s ) ;
28 disp ( At n=3 s e c o n d s : ) ;
29 t =3;
30 a = x (1 ,2* n -2) ;
31 b = y (1 ,n -2) ;
32 c = x (1 ,2* n -4) ;
33 disp (a , x ( 2 nn0 ) : ) ;
34 disp (b , i s n o t e q u a l t o y ( 2 nn0 ) : ) ;
35 disp (c , w h i l e x ( 2 n2n0 ) : ) ;
36 disp ( Hence t h e s y s t e m i s Time v a r i a n t ) ;
123
16 a = x (n -2) -x (n -2 -1) ;
17 disp (a , x ( n 2) : ) ;
18 disp (b , i s e q u a l t o y ( n2) : ) ;
19 disp ( Hence t h e s y s t e m i s S h i f t i n v a r i a n t / f i x e d );
124
27 disp ( At n=3 s e c o n d s : ) ;
28 t =3;
29 a = x (1 ,n -2) ;
30 b = y (1 ,n -2) ;
31 c =2* x (1 ,n -2) ;
32 disp (a , x ( nn0 ) : ) ;
33 disp (b , i s n o t e q u a l t o y ( nn0 ) : ) ;
34 disp (c , w h i l e ( nn0 ) x ( nn0 ) : ) ;
35 disp ( ( i i i ) Hence t h e s y s t e m i s Time v a r i a n t ) ;
125
s h o u l d be : ) ;
23 disp ( ( i ) Hence t h e s y s t e m i s l i n e a r ) ;
126
29 disp (a , e x ( nn0 ) : ) ;
30 disp (b , i s e q u a l t o y ( nn0 ) : ) ;
31 disp ( ( i i i ) Hence t h e s y s t e m i s Time i n v a r i a n t ) ;
127
Figure 7.1: Output of an LTI
128
8 n = -2:2;
9 c = gca () ;
10 c . y_location = o r i g i n ;
11 c . x_location = o r i g i n ;
12 plot2d2 (n ,x ,2) ;
13 title ( x ( t ) )
14 xlabel ( t )
15 figure (1) ;
16 n = -2:2;
17 c = gca () ;
18 c . y_location = o r i g i n ;
19 c . x_location = o r i g i n ;
20 plot2d2 (n ,y ,5) ;
21 title ( y ( t ) )
22 xlabel ( t )
23 z = conv (x , y ) ;
24 figure (2) ;
25 n = -3:5;
26 c = gca () ;
27 c . y_location = o r i g i n ;
28 c . x_location = o r i g i n ;
29 plot (n ,z ,2) ;
30 title ( C o n v o l u t e d s i g n a l z( t ) )
31 xlabel ( t )
129
Figure 7.2: Convolution
130
6 syms s t R C ;
7 Y1 =(1/( R * C ) ) /( s +1/( R * C ) ) ;
8 disp ( Y1 , L a p l a c e T r a n s f o r m Of d i f f e r e n t i a l Equation
is : )
9 y11 = ilaplace ( Y1 ,s , t ) ;
10 disp ( y11 , The I m p u l s e R e s p o n s e o f t h e System i s : ) ;
11 for k =0:10;
12 y1 ( k +1) = exp ( - k ) ;
13 end
14 k =0:10;
15 plot (k , y1 ) ;
16 title ( System R e s p o n s e t o i m p u l s e i n p u t ) ;
17 Y2 =(1/( R * C ) ) /( s ^2+ s /( R * C ) ) ;
18 disp ( Y2 , L a p l a c e T r a n s f o r m Of d i f f e r e n t i a l E q u a t i o n
is : )
19 y22 = ilaplace ( Y2 ,s , t ) ;
20 disp ( y22 , The S t e p R e s p o n s e o f t h e System i s : ) ;
21 for k =0:10;
22 y2 ( k +1) =1 - exp ( - k ) ;
23 end
24 figure (1) ;
25 k =0:10;
26 plot (k , y2 ) ;
27 title ( System R e s p o n s e t o S t e p i n p u t ) ;
131
Figure 7.3: Impulse and Step response
132
Figure 7.4: Impulse and Step response
133
4 clc ;
5 clear ;
6 syms s t R L ;
7 Y1 =(1/ s ) -(1/( s +( R / L ) ) ) ;
8 disp ( Y1 , L a p l a c e T r a n s f o r m Of d i f f e r e n t i a l Equation
is : )
9 y1 = ilaplace ( Y1 ,s , t ) ;
10 disp ( y1 , The S t e p R e s p o n s e o f t h e System i s : ) ;
11 // Taking R/L=1;
12 for k =0:10;
13 y1 ( k +1) =1 - exp ( - k ) ;
14 end
15 k =0:10;
16 plot (k , y1 ) ;
17 title ( System R e s p o n s e t o S t e p i n p u t ) ;
18 Y2 =(1/( s +( R / L ) ) ) ;
19 disp ( Y2 , L a p l a c e T r a n s f o r m Of d i f f e r e n t i a l E q u a t i o n
is : )
20 y2 = ilaplace ( Y2 ,s , t ) ;
21 disp ( y2 , The I m p u l s e R e s p o n s e o f t h e System i s : ) ;
22 for k =0:10;
23 y2 ( k +1) = exp ( - k ) ;
24 end
25 figure (1) ;
26 k =0:10;
27 plot (k , y2 ) ;
28 title ( System R e s p o n s e t o i m p u l s e i n p u t ) ;
134
Figure 7.5: Impulse and Step Response
135
Figure 7.6: Impulse and Step Response
136
s y s t e m s by
2 //P . Ramakrishna Rao
3 // C o n v o l u t i o n o f two s i g n a l s
4 clc ;
5 clear ;
6 clear x y n ;
7 x =[2 , -1 ,1 ,0 ,2];
8 y =[1 ,0 , -1 ,2];
9 n = -1:3;
10 c = gca () ;
11 c . y_location = o r i g i n ;
12 c . x_location = o r i g i n ;
13 plot2d3 (n ,x , -5) ;
14 title ( x ( k ) )
15 xlabel ( k )
16 figure (1) ;
17 n =0:3;
18 c = gca () ;
19 c . y_location = o r i g i n ;
20 c . x_location = o r i g i n ;
21 plot2d3 (n ,y , -5) ;
22 title ( y ( k ) )
23 xlabel ( k )
24 z = conv (x , y ) ;
25 figure (2) ;
26 n = -1:6;
27 c = gca () ;
28 c . y_location = o r i g i n ;
29 c . x_location = o r i g i n ;
30 plot2d3 (n ,z , -5) ;
31 title ( C o n v o l u t e d s i g n a l z( t ) )
32 xlabel ( t )
137
Figure 7.7: Convolution
138
Scilab code Exa 7.22 Convolution
139
Figure 7.8: Convolution
36 xlabel ( t ) ;
37 disp ( z (1) , z ( 0 ) ,z (4) , z ( 3 ) ,z (6) , z ( 5 ) ,z (11) , z
( 1 0 ) );
140
5 clear ;
6 clear x y n ;
7 for n =0:10;
8 x ( n +1) =(0.5) ^ n * u (n -2) ;
9 end
10 c = gca () ;
11 c . y_location = o r i g i n ;
12 c . x_location = o r i g i n ;
13 n =0:10;
14 plot2d3 (n ,x , -4) ;
15 title ( x ( n ) )
16 xlabel ( n )
17 for n =0:10;
18 y ( n +1) = u ( n ) ;
19 end
20 figure (1) ;
21 n =0:10;
22 c = gca () ;
23 c . y_location = o r i g i n ;
24 c . x_location = o r i g i n ;
25 plot2d3 (n ,y , -4) ;
26 title ( y ( k ) )
27 xlabel ( k )
28 z = conv (x , y ) ;
29 figure (2) ;
30 n =0:20;
31 c = gca () ;
32 c . y_location = o r i g i n ;
33 c . x_location = o r i g i n ;
34 plot2d3 (n ,z , -4) ;
35 title ( C o n v o l u t e d s i g n a l z( t ) )
36 xlabel ( t )
141
Figure 7.9: Convolution
142
Scilab code Exa 7.24 Step Response
143
Figure 7.10: Step Response
144
Figure 7.11: Step response
);
11 y2 =2*( a ^n -1) /( a -1) ;
12 disp ( y2 , The S t e p R e s p o n s e o f t h e System i s : ) ;
13 q =1;
14 a =0.5;
15 for k =0:0.1:5;
16 y2 ( q ) =2*(( a ^k -1) /( a -1) ) ;
17 q = q +1;
18 end
19 k =0:0.1:5;
20 plot (k , y2 ) ;
145
Scilab code Exa 7.33 Magnitude and Phase Response
146
Figure 7.12: Magnitude and Phase Response
147
Figure 7.13: Magnitude and Phase Response
148
Chapter 8
149
Figure 8.1: Magnitude and Phase Responses
19 title ( I m p u l s e R e s p o n s e ) ;
20 ylabel ( A m p l i t u d e ) ;
21 xlabel ( t i m e i n s e c o n d s ) ;
22 figure (1) ;
23 w = -5*2* %pi :0.01:5*2* %pi ;
24 plot (w , Hphs ) ;
25 title ( Phase R e s p o n s e ) ;
26 ylabel ( t h e t a (w) ) ;
27 xlabel ( w i n r a d i a n s / s e c o n d ) ;
150
Figure 8.2: Magnitude and Phase Responses
151
Scilab code Exa 8.2 Transfer Function of system
152
Figure 8.3: Transfer Function of system
153
Scilab code Exa 8.3 Magnitude and Phase Responses
154
Figure 8.4: Magnitude and Phase Responses
155
Figure 8.5: Magnitude and Phase Responses
156
6 z = %z ;
7 syms n z1 ;
8 X =( z -1) /(( z +(1/2) ) *( z -(1/5) ) )
9 disp (X , ( i ) System F u n c t i o n i s : ) ;
10 X1 = denom ( X ) ;
11 zp = roots ( X1 ) ;
12 X1 = ( z1 -1) /(( z1 +(1/2) ) *( z1 -(1/5) ) ) ;
13 F1 = X1 *( z1 ^( n -1) ) *( z1 - zp (1) )
14 F2 = X1 *( z1 ^( n -1) ) *( z1 - zp (2) )
15 h1 = limit ( F1 , z1 , zp (1) )
16 h2 = limit ( F2 , z1 , zp (2) )
17 h = h1 + h2 ;
18 disp ( ( i v ) U n i t s a m p l e r e s p o n s e s e q u e n c e : )
19 disp ( h * u ( n ) , h [ n ]= ) ;
20 for n =0:10;
21 w ( n +1) =( - 5.714*(0.2) ^n - 4.285*( - 0.5^ n ) ) ;
22 end
23 n =0:10;
24 plot (n , w ) ;
25 title ( ( i i i ) U n i t Sample R e s p o n s e S e q u e n c e ) ;
26 disp ( where z=e jw ,X , ( i ) T r a n s f e r F u n c t i o n i s : ) ;
157
Figure 8.6: system response
158
9 disp (X , ( i ) System F u n c t i o n i s : ) ;
10 X1 = denom ( X ) ;
11 zp = roots ( X1 ) ;
12 X1 = z1 ^2/( z1 -0.5) ^2;
13 F1 = X1 *( z1 ^( n -1) ) *( z1 -0.5) ^2;
14 h1 = limit ( F1 , z1 , zp (1) ) ;
15 h = h1 ;
16 disp ( ( i i i ) U n i t s t e p r e s p o n s e s e q u e n c e : )
17 disp ( h * u ( n ) , h [ n ]= ) ;
18 for n =0:20;
19 w1 ( n +1) =1 -(0.5) ^ n ;
20 end
21 n =0:20;
22 plot (n , w1 ) ;
23 title ( ( i i ) U n i t Sample R e s p o n s e S e q u e n c e ) ;
24 disp ( where z=e jw ,X , ( i v ) T r a n s f e r F u n c t i o n (H( e
jw ) ) i s : ) ;
159
Figure 8.7: System function
160
13 disp (Z , ( b ) LC Low p a s s F i l t e r : H( s ) ) ;
161
8 H = s ^3/( s ^3+6* s ^2++11* s +6) ;
9 H1 = denom ( H ) ;
10 a = roots ( H1 ) ;
11 H2 =5*( s1 ^3/( s1 - a (1) ) ) *( s1 /( s1 - a (2) ) ) *( s1 /( s1 - a (3) ) ) ;
12 disp ( H2 , ( i i ) C a s c a d e Form : H( s ) ) ;
13 h1 = s1 ^3*( s1 - a (1) ) /(( s1 +1) *( s1 +2) *( s1 +3) ) ;
14 h2 = s1 ^3*( s1 - a (2) ) /(( s1 +1) *( s1 +2) *( s1 +3) ) ;
15 h3 = s1 ^3*( s1 - a (3) ) /(( s1 +1) *( s1 +2) *( s1 +3) ) ;
16 A = limit ( h1 , s1 , a (1) ) /( s - a (1) ) ;
17 B = limit ( h2 , s1 , a (2) ) /( s - a (2) ) ;
18 C = limit ( h3 , s1 , a (3) ) /( s - a (3) ) ;
19 Z =5*(1+ A + B + C ) ;
20 disp (Z , ( i i i ) P a r a l l e l Form R e a l i z a t i o n : H( s ) ) ;
162
19 w2 = limit ( F2 ,z , a (2) )
20 w = w1 + w2 ;
21 disp (w , ( b ) h ( n ) )= ) ;
22 z = %z ;
23 x11 = z * x1 /3
24 x12 = z * x2 /3
25 disp ( x11 , ( c ) P a r a l l e l r e a l i z a t i o n : H1 ( z ) ) ;
26 disp ( x12 , H2 ( z ) )
163
Chapter 9
164
Figure 9.1: Convolution
165
Figure 9.2: Convolution
166
8 x ( n ) = -2* u (t -0.5) +2* u (t -1.5) ;
9 y ( n ) =( t +1) * u ( t +1) -( t +1) * u (t -2) ;
10 n = n +1;
11 end
12 z = conv (x , y ) ;
13 t = -5:0.1:5;
14 plot2d2 (t ,x ,5) ;
15 title ( x ( t ) ) ;
16 figure (1) ;
17 t = -5:0.1:5;
18 plot2d (t ,y ,2) ;
19 title ( y ( t ) ) ;
20 figure (2) ;
21 t = -10:0.1:10;
22 plot2d (t ,z ,6) ;
23 title ( C o n v o l u t i o n ) ;
167
Figure 9.3: Autocorrelation
168
Figure 9.4: Autocorrelation
169
Figure 9.5: Autocorrelation
170
3 clc ;
4 clear ;
5 clear z x y t T ;
6 n =1;
7 for t = -10:0.01:10;
8 x ( n ) = exp ( - t ) * u ( t ) ;
9 n = n +1;
10 end
11 t = -10:0.01:10;
12 plot (t , x ) ;
13 title ( x ( t ) ) ;
14 n =1;
15 for T = -10:0.1:0;
16 z ( n ) = integrate ( exp ( t ) exp (Tt ) , t ,0 ,1000) ;
17 n = n +1;
18 end
19 n =1;
20 for T =0.1:0.1:10;
21 z ( n +101) = integrate ( exp ( t ) exp (Tt ) , t ,T
,1000) ;
22 n = n +1;
23 end
24 figure (1) ;
25 T = -10:0.1:10;
26 plot (T , z ) ;
27 title ( Rxx (T) ) ;
28 xlabel ( t i n s e c o n d s ) ;
171
Figure 9.6: Autocorrelation
172
Figure 9.7: Autocorrelation
173
by
2 //P . Ramakrishna Rao
3 clc ;
4 clear ;
5 clear z x y t T ;
6 A =1;
7 n =1;
8 wo =2* %pi ;
9 theta = %pi /2;
10 for t = -5:0.01:5;
11 x ( n ) = A * cos ( wo * t + theta ) ;
12 n = n +1;
13 end
14 t = -5:0.01:5;
15 plot (t , x ) ;
16 title ( x ( t ) ) ;
17 n =1;
18 for T = -5:0.1:5;
19 z ( n ) =( A ^2/2) * cos ( wo * T ) ;
20 n = n +1;
21 end
22 figure (1) ;
23 T = -5:0.1:5;
24 plot (T , z ) ;
25 title ( Rxx (T) ) ;
26 xlabel ( t i n s e c o n d s )
174
Figure 9.8: Autocorrelation
175
Figure 9.9: Autocorrelation
176
2 //P . Ramakrishna Rao
3 clc ;
4 clear ;
5 clear z x y t T A ;
6 A =4;
7 T0 =2;
8 n =1;
9 for T =0:0.1: T0 ;
10 if T < T0 /2 then
11 x(n)=A;
12 else x ( n ) =0;
13 end
14 n = n +1;
15 end
16 T =0:0.1: T0 ;
17 plot2d2 (T ,x ,6) ;
18 title ( x ( t ) ) ) ;
19 xlabel ( t i n s e c o n d s ) ;
20 n =1;
21 for T =0:0.1: T0 ;
22 z ( n ) =(1/ T0 ) * integrate ( A2 , t ,T , T0 /2) ;
23 n = n +1;
24 end
25 T =0:0.1: T0 ;
26 figure (1) ;
27 plot (T , z ) ;
28 title ( Rxx (T) ) ;
29 xlabel ( T i n s e c o n d s ) ;
177
Figure 9.10: PSD
4 clc ;
5 clear ;
6 disp ( Maximum V a l u e o f ACF=Rxx ( 0 ) ) ;
7 x =200* integrate ( exp ( 2 t ) , t ,0 ,1000) ;
8 disp (x , Energy i n x ( t )= ) ;
178
3 // Power S p e c t r a l D e n s i t y
4 clear ;
5 clc ;
6 clear f n ;
7 fo =2;
8 n =1;
9 RC =1/(2* %pi *10^3) ;
10 w =4* %pi *10^3
11 H =1/(1+ %i * w * RC ) ;
12 disp (H , H( f ) ) ;
13 X =( abs ( H ) ) ^2;
14 for f = -5:5
15 Pxx ( n ) =25*[ delta (f - fo ) + delta ( f + fo ) ];
16 Pyy ( n ) = X * Pxx ( n ) ;
17 n = n +1;
18 end
19 disp ( Pxx , Pxx= ) ;
20 disp ( Pyy , Pyy= ) ;
21 f = -5:5;
22 plot2d3 (f , Pyy , -2) ;
23 title ( Power S p e c t r a l D e n s i t y ) ;
24 ylabel ( Pyy ( f ) ) ;
25 xlabel ( f i n Hz ) ;
179
Chapter 10
180
Figure 10.1: Cross Correlation
181
Figure 10.2: Cross Correlation Sequence
17 title ( C r o s s C o r r e l a t i o n s e g u e n c e o u t p u t ) ;
182
Figure 10.3: Auto Correlation
7 y =[0 ,3 ,0 , -3 ,6];
8 // c o m p u t a t i o n o f c r o s s c o r r e l a t i o n s e q u e n c e ;
9 n1 = max ( size ( y ) ) -1;
10 n2 = max ( size ( x ) ) -1;
11 r = xcorr (x ,y , n1 ) ;
12 n = -4:4;
13 a = gca () ;
14 a . x_location = o r i g i n ;
15 a . y_location = o r i g i n ;
16 plot2d3 (n ,r , -9) ;
17 title ( r x y c r o s s c o r r e l a t i o n ) ;
183
Scilab code Exa 10.4 Auto Correlation
184
Figure 10.4: Auto Correlation
185
Figure 10.5: Auto Correlation
13 length ( x )
14 // c o m p u t a t i o n o f a u t o c o r r e l a t i o n s e q u e n c e ;
15 r = xcorr ( x ) ;
16 n = -60:60;
17 a = gca () ;
18 a . x_location = o r i g i n ;
19 a . y_location = o r i g i n ;
20 plot2d3 (n ,r , -4) ;
21 title ( r x x a u t o c o r r e l a t i o n ) ;
186
1 // S c i l a b Code f o r Example 1 0 . 8 o f S i g n a l s and
s y s t e m s by
2 //P . Ramakrishna Rao
3 // Auto C o r r e l a t i o n
4 clear ;
5 clc ;
6 clear x n a ;
7 k =1;
8 a =0.8;
9 for n = -30:30;
10 x ( k ) = a ^( n ) * u ( n ) ;
11 k = k +1;
12 end
13 length ( x )
14 // c o m p u t a t i o n o f a u t o c o r r e l a t i o n s e q u e n c e ;
15 r = xcorr ( x ) ;
16 n = -60:60;
17 a = gca () ;
18 a . x_location = o r i g i n ;
19 a . y_location = o r i g i n ;
20 plot2d3 (n ,r , -4) ;
21 title ( r x x a u t o c o r r e l a t i o n ) ;
187
Figure 10.6: System response
188
8 x =[1 ,1 ,1 ,1 ,0 ,0];
9 y =[1 ,3 ,6 ,10 ,12 ,12 ,10 ,6 ,3 ,1];
10 h (1) = y (1) / x (1) ;
11 for n =2:7
12 for k =1: n -1
13 z ( k ) =( h ( k ) * x (n - k ) ) ;
14 h ( n ) =( y ( n ) - sum ( z ) ) ;
15 end
16 end
17 disp (h , h ( n ) ) ;
18 n =1:7;
19 a = gca () ;
20 a . x_location = o r i g i n ;
21 a . y_location = o r i g i n ;
22 plot2d3 (n ,h , -4) ;
23 title ( System R e s p o n s e h ( n ) ) ;
189
Chapter 11
190
Figure 11.1: Hilbert Transform
191
Figure 11.2: Hilbert Transform
192
Figure 11.3: Hilbert Transform
15 title ( Given S i g n a l x ( t ) ) ;
16 xlabel ( t i m e t> ) ;
17 figure (1) ;
18 t = -1:0.1:1;
19 plot (t , imag ( x ) ) ;
20 title ( H i l b e r t T r a n s f o r m ) ;
21 xlabel ( t i m e t> ) ;
193
Figure 11.4: Hilbert Transform
194
1 // S c i l a b Code f o r Example 1 1 . 2 o f S i g n a l s and
s y s t e m s by
2 //P . Ramakrishna Rao
3 // H i l b e r t T r a n s f o r m
4 clc ;
5 clear ;
6 n =1;
7 for t = -1:0.01:1
8 xr ( n ) = cos (2* %pi * t ) ;
9 n = n +1;
10 end
11 // Computing H i l b e r t b T r a n s f o r m
12 x = hilbert ( xr ) ;
13 t = -1:0.01:1;
14 plot (t , xr ) ;
15 title ( Given S i g n a l x ( t ) ) ;
16 xlabel ( t i m e t> ) ;
17 figure (1) ;
18 t = -1:0.01:1;
19 plot (t , imag ( x ) ) ;
20 title ( H i l b e r t T r a n s f o r m ) ;
21 xlabel ( t i m e t> ) ;
195
Figure 11.5: Hilbert Transform
196
Figure 11.6: Hilbert Transform
197
6 clear ;
7 n =1;
8 for t = -1:0.01:1
9 xr ( n ) = exp ( %i *2* %pi * t ) ;
10 n = n +1;
11 end
12 // Computing H i l b e r t b T r a n s f o r m
13 x1 = hilbert ( real ( xr ) ) ;
14 x2 = hilbert ( imag ( xr ) ) ;
15 x = x1 + x2 ;
16 t = -1:0.01:1;
17 plot (t , xr ) ;
18 title ( Given S i g n a l x ( t ) ) ;
19 xlabel ( t i m e t> ) ;
20 figure (1) ;
21 t = -1:0.01:1;
22 plot (t , imag ( x ) ) ;
23 title ( H i l b e r t T r a n s f o r m ) ;
24 xlabel ( t i m e t> ) ;
198
Figure 11.7: Hilbert Transform
199
Figure 11.8: Hilbert Transform
200
9 for t = -10:0.01:10;
10 if t > - T /2 & t < T /2 then
11 x(n)=A;
12 n = n +1;
13 else x ( n ) =0;
14 n = n +1;
15 end
16 end
17 t = -10:0.01:10;
18 // S i g n a l x ( t )
19 plot (t , x ) ;
20 title ( Given S i g n a l x ( t ) ) ;
21 xlabel ( t i m e t> ) ;
22 // Computing H i l b e r t T r a n s f o r m
23 xr = hilbert ( x ) ;
24 xr_imag = imag ( xr ) ;
25 figure (1) ;
26 t = -10:0.01:10;
27 plot (t , xr_imag ) ;
28 title ( H i l b e r t t r a n s f o r m and a s s o c i a t e d s i g n a l ) ;
29 xlabel ( t i m e t> ) ;
201









