Signals and Systems - Prof - Priyen S. Patel
Signals and Systems - Prof - Priyen S. Patel
Signals and Systems - Prof - Priyen S. Patel
Solutions provided by
Prof Priyen S. Patel
Electrical Engineering
Swarnim Startup & Innovation University
May 9, 2024
2
10 Develop a program to obtain Z transform of basic function
using Scilab. 36
3
List of Experiments
4
List of Figures
10.1 Z transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5
Experiment: 1
1 // Experiment −1
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program t o g e n e r a t e F o l l o w i n g
Continuous S i g n a l a ) S i n u s o i d a l ; b ) Cosine ; c )
T r i a n g l e ; d ) S q u a r e Wave .
7
8 clear all
9 clc
10 V = input ( ’ E n t e r t h e v a l u e o f V o l t a g e i n volts : ’)
// Example v= 20 V o l t
11 f = input ( ’ E n t e r t h e v a l u e o f f r e q u e n c y i n H e r t z : ’
) // Example f =50 Hz
6
12 t =0:1/(1000* f ) :5/ f ;
13 // G e n e r a t i o n o f S i n e Wave .
14 y1 = V *( sin (2* %pi * f * t ) ) ;
15 xgrid ;
16 subplot (221)
17 plot (t , y1 )
18 xlabel ( ’ Time ( s e c ) ’ )
19 ylabel ( ’ y = v ∗ s i n w t ’ )
20 title ( ’ S i n e wave ’ ,” f o n t s i z e ” ,4)
21 // G e n e r a t i o n o f Cos Wave .
22 y2 = V *( cos (2* %pi * f * t ) ) ;
23 subplot (222)
24 plot (t , y2 )
25 xgrid ;
26 xlabel ( ’ Time ( s e c ) ’ )
27 ylabel ( ’ y = v ∗ c o s w t ’ )
28 title ( ’ C o s i n e wave ’ ,” f o n t s i z e ” ,4)
29 // G e n e r a t i o n o f T r i a n g l e Wave .
30 t1 =0:( %pi /4) :(4* %pi ) ;
31 y3 = V * sin (2* t1 ) ;
32 a = gca () ;
33 subplot (223)
34 plot ( t1 , y3 ) ;
35 xgrid ;
36 xlabel ( ’ Time ( s e c ) ’ )
37 ylabel ( ’ A m p l i t u d e ’ )
38 title ( ’ T r i a n g l e wave ’ ,” f o n t s i z e ” ,4)
39 // G e n e r a t i o n o f S q u a r e Wave .
40 t3 =0:1/(1000* f ) :0.6;
41 y4 =( V -1) * squarewave (2* %pi *10* t3 ) ;
42 subplot (224)
43 plot ( t3 , y4 )
44 xgrid ;
45 xlabel ( ’ Time ( s e c ) ’ )
46 ylabel ( ’ A m p l i t u d e ’ )
47 title ( ’ S q u a r e wave ’ ,” f o n t s i z e ” ,4)
48
49 // . . . C o n s o l Window e n t r y . . .
7
Figure 1.1: Continuous Signal
50 // E n t e r t h e v a l u e o f V o l t a g e i n v o l t s : 20
51 // E n t e r t h e v a l u e o f f r e q u e n c y i n H e r t z : 50
8
Experiment: 2
1 // Experiment −2
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program t o g e n e r a t e F o l l o w i n g
D i s c r e t e S i g n a l a ) I m p u l s e ; b ) S t e p ; c )Ramp ; d )
Exponential .
7
8 clc ;
9 clf ;
10 clear all ;
11 L = input ( ” E n t e r t h e Length o f s i g n a l =” ) ; // L=10 (
must be g r e a t e r t h a n 2 )
12 b = input ( ” E n t e r t h e v a l u e o f E x p o n e n t i a l co−
9
e f f i c i e n t =” ) ; // b = 0 . 5
13 // p o s i t i v e v a l u e f o r i n c r e m e n t a l E x p o n e n t i a l s i g n a l
14
15 n=-L:L;
16 // G e n e r a t i o n o f U n i t I m p u l s e S i g n a l
17 x1 =[ zeros (1 , L ) , ones (1 ,1) , zeros (1 , L ) ];
18 a = gca () ;
19 a . y_location = ” m i d d l e ”
20 subplot (221)
21 plot2d3 (n , x1 ) ;
22 title ( ’ U n i t I m p u l s e S i g n a l ’ ,” f o n t s i z e ” ,3 ) ;
23 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
24 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
25 // G e n e r a t i o n o f U n i t S t e p S i g n a l
26 x2 =[ zeros (1 , L ) , ones (1 , L +1) ];
27 a = gca () ;
28 a . y_location = ” m i d d l e ” ;
29 subplot (222)
30 plot2d3 (n , x2 ) ;
31 title ( ’ U n i t S t e p ’ ,” f o n t s i z e ” ,3 ) ;
32 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
33 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
34 // G e n e r a t i o n o f Ramp S i g n a l
35 x3 =[ zeros (1 , L ) ,0: L ];
36 a = gca () ;
37 a . y_location = ’ m i d d l e ’ ;
38 subplot (223)
39 plot2d3 (n , x3 ) ;
40 title ( ’Ramp o f s i g n a l ’ ,” f o n t s i z e ” ,3) ;
41 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
42 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
43
44 // G e n e r a t i o n o f E x p o n e n t i a l S i g n a l
45 t = -2:0.1:2;
46 x4 = exp ( b * t ) ;
47 subplot (224)
48 plot2d3 ( x4 ) ;
49 title ( ’ E x p o n e n t i a l S i g n a l ’ ,” f o n t s i z e ” ,3 ) ;
10
Figure 2.1: Discrete wave with positive exponential
1 // Experiment −2
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program t o g e n e r a t e F o l l o w i n g
D i s c r e t e S i g n a l a ) I m p u l s e ; b ) S t e p ; c )Ramp ; d )
Exponential .
7
11
8 clc ;
9 clf ;
10 clear all ;
11 L = input ( ” E n t e r t h e Length o f s i g n a l =” ) ; // L=10 (
must be g r e a t e r t h a n 2 )
12 b = input ( ” E n t e r t h e v a l u e o f E x p o n e n t i a l co−
e f f i c i e n t =” ) ; // b = 0.5
13 n=-L:L;
14 // G e n e r a t i o n o f U n i t I m p u l s e S i g n a l
15 x1 =[ zeros (1 , L ) , ones (1 ,1) , zeros (1 , L ) ];
16 a = gca () ;
17 a . y_location = ” m i d d l e ”
18 subplot (221)
19 plot2d3 (n , x1 ) ;
20 title ( ’ U n i t I m p u l s e S i g n a l ’ ,” f o n t s i z e ” ,3 ) ;
21 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
22 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
23 // G e n e r a t i o n o f U n i t S t e p S i g n a l
24 x2 =[ zeros (1 , L ) , ones (1 , L +1) ];
25 a = gca () ;
26 a . y_location = ” m i d d l e ” ;
27 subplot (222)
28 plot2d3 (n , x2 ) ;
29 title ( ’ U n i t S t e p ’ ,” f o n t s i z e ” ,3 ) ;
30 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
31 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
32 // G e n e r a t i o n o f Ramp S i g n a l
33 x3 =[ zeros (1 , L ) ,0: L ];
34 a = gca () ;
35 a . y_location = ’ m i d d l e ’ ;
36 subplot (223)
37 plot2d3 (n , x3 ) ;
38 title ( ’Ramp o f s i g n a l ’ ,” f o n t s i z e ” ,3) ;
39 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
40 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
41
42 // G e n e r a t i o n o f N e g e t i v e v a l u e E x p o n e n t i a l S i g n a l
43 t = -2:0.1:2;
12
Figure 2.2: Discrete waves with negative exponential
44 x4 = exp ( - b * t ) ;
45 subplot (224)
46 plot2d3 ( x4 ) ;
47 title ( ’ E x p o n e n t i a l S i g n a l ’ ,” f o n t s i z e ” ,3 ) ;
48 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
49 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
50
51 // . . . C o n s o l e i n p u t
52 // E n t e r t h e Length o f s i g n a l =5
53
54 // E n t e r t h e v a l u e o f E x p o n e n t i a l co− e f f i c i e n t =0.5
13
Experiment: 3
1 // Experiment −3
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : D e v e l o p a program f o r a d d i t i o n o f two
Continuous s i g n a l s using S c i l a b .
7
8
9 // A d d i t i o n o f C o n t i n u o u s S i g n a l s
10 clc ;
11 clear all ;
12 V = input ( ’ E n t e r t h e v a l u e o f V o l t a g e i n volts : ’)
// Example v= 5 V o l t
13 f = input ( ’ E n t e r t h e v a l u e o f S i g n a l 1 f r e q u e n c y i n
14
Figure 3.1: Addition of Continuous signal
15
35 // . . . . . . . . . . . . . . E x e c u t i o n C o n s o l V a l u e
.............//
36 // E n t e r t h e v a l u e o f V o l t a g e i n v o l t s : 5
37 // E n t e r t h e v a l u e o f S i g n a l 1 f r e q u e n c y i n H e r t z :
50
38 // E n t e r t h e number o f h a r m o n i c i n s i g n a l : 3
16
Experiment: 4
1 // Experiment −3
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : D e v e l o p a program f o r a d d i t i o n o f two
d i s c r e t e s i g n a l s using Scilab .
7
8
9 // A d d i t i o n o f D i s c o n t i n u o u s S i g n a l s
10
11 clc ;
12 clear all ;
13
14 L = input ( ” E n t e r t h e Length o f s i g n a l =” ) ; // L=10 (
17
Figure 4.1: Addition of Discrete signal
must be g r e a t e r t h a n 2 )
15 n=-L:L;
16 // G e n e r a t i o n o f S t e p S i g n a l
17 x1 =5*[ zeros (1 , L ) , ones (1 , L +1) ];
18 a = gca () ;
19 a . y_location = ” m i d d l e ” ;
20 subplot (131)
21 plot2d3 (n , x1 ) ;
22 title ( ’ S t e p S i g n a l ’ ,” f o n t s i z e ” ,3 ) ;
23 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
24 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
25 // G e n e r a t i o n o f Ramp S i g n a l
26 x2 =[ zeros (1 , L ) ,0: L ];
27 a = gca () ;
28 a . y_location = ’ m i d d l e ’ ;
29 subplot (132)
30 plot2d3 (n , x2 ) ;
31 title ( ’Ramp o f s i g n a l ’ ,” f o n t s i z e ” ,3) ;
32 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
33 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
34 x3 = x1 + x2 ; // A d d i t i o n o f two s i g n a l s
35 subplot (133)
36 plot2d3 (n , x3 ) ;
18
37 title ( ’ A d d i t i o n o f s i g n a l ’ ,” f o n t s i z e ” ,4)
38 xlabel ( ’ Number o f Sample−−−−−−> ’ )
39 ylabel ( ’ A m p l i t u d e −−−−−> ’ )
40
41 // . . . . . . . . . . . . . . E x e c u t i o n C o n s o l V a l u e
.............//
42 // E n t e r t h e Length o f s i g n a l =5
19
Experiment: 5
1 // Experiment −5
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r ALIASING P r o c e s s u s i n g
scilab
7
8 clc ;
9
10 clear all ;
11
12 f = input ( ” E n t e r t h e f r e q u e n c y o f c o n t i n u o u s s i g n a l =” )
; // f= 1 0 0 0
13 v = input ( ” E n t e r t h e A m p l i t u d e o f c o n t i n u o u s s i g n a l =” )
; // v = 10
14 fs = input ( ” E n t e r t h e s a m p l i n g F r e q u e n c y Fs =” ) ; //
20
Figure 5.1: Aliasing Effect
f s = 2 0 0 0 Hz
15 t =0:0.00001:1/ f ;
16 x1 = v * sin (2* %pi * f * t ) ;
17 subplot (3 ,2 ,1)
18 a = gca () ;
19 a . x_location = ” o r i g i n ” ;
20 a . y_location = ” o r i g i n ” ;
21 plot (t , x1 )
22 xlabel ( ’ Time ( s e c )−−−−> ’ )
23 ylabel ( ’ A m p l i t u d e −−−−> ’ )
24 title ( ’ C o n t i n u o u s Time s i g n a l ’ ,” f o n t s i z e ” ,4)
25 f2 = f / fs ;
26 n =0:0.01:1/ f2 ;
27 y1 =3* sin (2* %pi * f2 * n ) ;
28 subplot (3 ,2 ,2)
29 a = gca () ;
30 a . x_location = ” o r i g i n ” ;
31 a . y_location = ” o r i g i n ” ;
32 plot2d3 ( ” gnn ” ,n , y1 )
33 xlabel ( ’ Time ( s e c )−−−−> ’ )
34 ylabel ( ’ A m p l i t u d e −−−−> ’ )
35 title ( ’ D i s c r e t e Time s i g n a l ’ ,” f o n t s i z e ” ,4)
36 x2 = 250;
21
37 y2 =3* sin (2* %pi *( x2 / fs ) * n ) ;
38 subplot (3 ,2 ,3)
39 a = gca () ;
40 a . x_location = ” o r i g i n ” ;
41 a . y_location = ” o r i g i n ” ;
42 plot2d3 ( ” gnn ” ,n , y2 )
43 title ( ’ S a m p l e s o f 250 Hz s i g n a l w i t h f s Hz ’ ,”
f o n t s i z e ” ,4)
44 x3 = 750;
45 y3 = 3* sin (2* %pi *( x3 / fs ) * n ) ;
46 subplot (3 ,2 ,4)
47 a = gca () ;
48 a . x_location = ” o r i g i n ” ;
49 a . y_location = ” o r i g i n ” ;
50 plot2d3 ( ” gnn ” ,n , y3 )
51 title ( ’ S a m p l e s o f 750 Hz s i g n a l w i t h f s Hz ’ ,”
f o n t s i z e ” ,4)
52 x4 = 3000;
53 y4 = 3* sin (2* %pi *( x4 / fs ) * n ) ;
54 subplot (3 ,2 ,5)
55 a = gca () ;
56 a . x_location = ” o r i g i n ” ;
57 a . y_location = ” o r i g i n ” ;
58 plot2d3 ( ” gnn ” ,n , y4 )
59 title ( ’ S a m p l e s o f 3 0 0 0 Hz s i g n a l w i t h f s Hz ’ ,”
f o n t s i z e ” ,4)
60 x5 = 12500;
61 y5 = 3* sin (2* %pi *( x5 / fs ) * n ) ;
62 subplot (3 ,2 ,6)
63 a = gca () ;
64 a . x_location = ” o r i g i n ” ;
65 a . y_location = ” o r i g i n ” ;
66 plot2d3 ( ” gnn ” ,n , y5 )
67 title ( ’ S a m p l e s o f 1 2 5 0 0 Hz s i g n a l w i t h f s Hz ’ ,”
f o n t s i z e ” ,4)
68 // Example
69 // E n t e r t h e f r e q u e n c y o f Co n t i n
uo u s Time S i g n a l : = 1 0 0 0
22
70 // E n t e r t h e S a m p l i n g f r e q u e n c y Fs=
2000
23
Experiment: 6
1 // Experiment −6
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r L i n e a r C o n v o l u t i o n o f
two s e q u e n c e s u s i n g s c i l a b
7 clc ;
8 clear ;
9 x = input ( ”ENTER THE FIRST SEQUENCE [ u s e s q u a r e
b r e a c k t − a r r e y form ]= ” ) ; // x ( n ) =[1 2 3 4 ]
10 h = input ( ”ENTER THE SECOND SEQUENCE =” ) ; // h ( n )
=[1 2 3 ]
11 l = length ( x ) + length ( h ) -1;
12 y = convol (x , h )
24
Figure 6.1: Linear Convolution
13 disp (y , ’ L i n e a r c o n v o l u t i o n i s = ’ )
14 subplot (311)
15 plot2d3 ( ’ gnn ’ ,x ) ;
16 a = gca () ;
17 a . x_location = ” o r i g i n ” ;
18 a . y_location = ” o r i g i n ” ;
19 title ( ’ S i g n a l − 1 ’ ,” f o n t s i z e ” ,3 ) ;
20 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
21 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
22 subplot (312)
23 plot2d3 ( h ) ;
24 a = gca () ;
25 a . x_location = ” o r i g i n ” ;
26 a . y_location = ” o r i g i n ” ;
27 title ( ’ S i g n a l − 2 ’ ,” f o n t s i z e ” ,3 ) ;
28 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
29 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
30 subplot (313)
31 plot2d3 ( y ) ;
32 a = gca () ;
33 a . x_location = ” o r i g i n ” ;
34 a . y_location = ” o r i g i n ” ;
35 title ( ’LINEAR CONVOLUTION ’ ,” f o n t s i z e ” ,3 ) ;
25
36 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
37 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
38
39 // . . . . . . . . E x e c u t i o n i n s c i l a b c o n s o l e . . . .
40
41 //ENTER THE FIRST SEQUENCE [ u s e s q u a r e b r e a c k t −
a r r e y form ]= [ 1 2 3 4 ]
42 //ENTER THE SECOND SEQUENCE =[1 2 3 ]
43 //−−−−−−−−Answer o f l i n e a r c o n v o l u t i o n −−−−−−−−
44 // L i n e a r c o n v o l u t i o n i s =
45
46 // 1. 4. 10. 16. 17. 12.
26
Experiment: 7
1 // Experiment −7
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r c i r c u l a r C o n v o l u t i o n o f
two s e q u e n c e s u s i n g s c i l a b
7 clc ;
8 clf () ;
9 clear ;
10 x = input ( ”ENTER THE FIRST SEQUENCE [ u s e s q u a r e
b r a c k e t − a r r a y form ]= ” ) ; // x ( n ) =[1 2 3 5 6
4]
11 h = input ( ”ENTER THE SECOND SEQUENCE =” ) ; // h ( n )
=[1 2 3 1 ]
27
Figure 7.1: Circular Convolution
12 N1 = length ( x ) ;
13 N2 = length ( h ) ;
14 N = max ( N1 , N2 ) ;
15 N3 = N1 - N2 ;
16 if ( N3 >=0) then
17 h =[ h , zeros (1 , N3 ) ];
18 else
19 x =[ x , zeros (1 , - N3 ) ];
20 end
21 for n =1: N
22 y ( n ) =0;
23 for i =1: N
24 j =n - i +1;
25 if (j <=0)
26 j=N+j;
27 end
28 y(n)=y(n)+x(i)*h(j)
29 end
30 end
31 disp (y , ’ C i r c u l a r c o n v o l u t i o n i s = ’ )
32 subplot (311)
33 plot2d3 ( ’ gnn ’ ,x ) ;
34 a = gca () ;
28
35 a . x_location = ” o r i g i n ” ;
36 a . y_location = ” o r i g i n ” ;
37 title ( ’ S i g n a l − 1 ’ ,” f o n t s i z e ” ,3 ) ;
38 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
39 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
40 subplot (312)
41 plot2d3 ( ’ gnn ’ ,h ) ;
42 a = gca () ;
43 a . x_location = ” o r i g i n ” ;
44 a . y_location = ” o r i g i n ” ;
45 title ( ’ S i g n a l − 2 ’ ,” f o n t s i z e ” ,3 ) ;
46 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
47 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
48 subplot (313)
49 plot2d3 ( ’ gnn ’ ,y ) ;
50 a = gca () ;
51 a . x_location = ” o r i g i n ” ;
52 a . y_location = ” o r i g i n ” ;
53 title ( ’CIRCULAR CONVOLUTION ’ ,” f o n t s i z e ” ,3 ) ;
54 xlabel ( ’ Number o f Sample−−−−−−> ’ ) ;
55 ylabel ( ’ A m p l i t u d e −−−−−> ’ ) ;
56
57
58 // . . . . Execution in Scilab 5 . 4 . 1 console . . . .
59
60 //ENTER THE FIRST SEQUENCE [ u s e s q u a r e b r e a c k t −
a r r e y form ]= [ 1 2 3 5 6 4 ]
61 //ENTER THE SECOND SEQUENCE =[1 2 3 1 ]
62
63 // C i r c u l a r c o n v o l u t i o n i s =
64
65 // 32 22 14 18 27 34
29
Experiment: 8
1 // Experiment −8
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r P e r f o r m i n g c r o s s
c o r r e l a t i o n o p e r a t i o n u s i n g SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 x1 = input ( ”ENTER THE FIRST SEQUENCE 01 [ u s e s q u a r e
b r a c k e t − a r r a y form ]= ” ) ; // [ 1 2 1 1 ]
12 x2 = input ( ”ENTER THE FIRST SEQUENCE 02 [ u s e s q u a r e
b r a c k e t − a r r a y form ]= ” ) ; // [ 1 1 2 1 ]
30
Figure 8.1: Cross correlation
31
correlation
32 [ ind ’ ,c ’]
33 disp (c , ’ C r o s s C o r r e l a t i o n S e q u e n c e i s = ’ )
34 subplot (2 ,2 ,3)
35 plot2d3 ( ’ gnn ’ ,c )
36 a = gca () ;
37 a . x_location = ” o r i g i n ” ;
38 a . y_location = ” o r i g i n ” ;
39 xlabel ( ” Sample −−−−−−>” ,” f o n t s i z e ” ,4) ;
40 ylabel ( ” A m p l i t u d e −−−−−−−>” ,” f o n t s i z e ” ,4) ;
41 title ( ” C r o s s C o r r e l a t i o n S e q u e n c e ” ,” f o n t s i z e ” ,4) ;
42
43 // . . . . . Execution in Consol .......
44
45 //ENTER THE FIRST SEQUENCE 01 [ u s e s q u a r e b r e a c k t −
a r r e y form ]= [ 1 2 1 1 ]
46 //ENTER THE FIRST SEQUENCE 02 [ u s e s q u a r e b r e a c k t −
a r r e y form ]= [ 1 1 2 1 ]
47 //ENTER THE A r r e y l e n g t h o f s e q u e n c e 2 from s t a r t i n g
p o i n t [ u s e s q u a r e b r e a c k t − a r r e y form ]= [ 1 2 3
4]
48 //ENTER THE A r r e y l e n g t h o f s e q u e n c e 2 from s t a r t i n g
p o i n t [ u s e s q u a r e b r e a c k t − a r r e y form ]= [ 1 2 3
4]
49
50 // C r o s s C o r r e l a t i o n S e q u e n c e i s =
51
52 // 1. 4. 6. 6. 5. 2. 1.
32
Experiment: 9
1 // Experiment −9
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r P e r f o r m i n g Auto
c o r r e l a t i o n o p e r a t i o n u s i n g SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 x1 = input ( ”ENTER THE FIRST SEQUENCE 01 [ u s e s q u a r e
b r a c k e t − a r r a y form ]= ” ) ; // [ 2 −1 2 3 1 ]
12 n = length ( x1 ) ;
13 s1 = input ( ”ENTER THE s t a r t i n g p o i n t o f a r r a y = ”);
33
Figure 9.1: Auto correlation
// −2
14 e1 = s1 +n -1;
15 n1 = s1 :1: e1 ;
16 subplot (2 ,1 ,1)
17 plot2d3 ( ’ gnn ’ ,n1 , x1 ) ;
18 ylabel ( ” A m p l i t u d e −−−−−−−>” ) ;
19 title ( ” S e q u e n c e − 01 ” ) ;
20 a = gca () ;
21 a . x_location = ” o r i g i n ” ;
22 a . y_location = ” o r i g i n ” ;
23 x2 = x1 ( $ : -1:1) ;
24 nl = s1 + s1 ;
25 nh = nl + n1 + n1 -2;
26 c = convol ( x1 , x2 ) // f u n c t i o n f o r Auto c o r r e l a t i o n
27 disp (c , ’ C r o s s C o r r e l a t i o n S e q u e n c e i s = ’ )
28 subplot (2 ,1 ,2)
29 plot2d3 ( ’ gnn ’ ,c )
30 a = gca () ;
31 a . x_location = ” o r i g i n ” ;
32 a . y_location = ” o r i g i n ” ;
33 xlabel ( ” Sample −−−−−−>” ) ;
34 ylabel ( ” A m p l i t u d e −−−−−−−>” ) ;
35 title ( ” Auto C o r r e l a t i o n S e q u e n c e ” ,” f o n t s i z e ” ,3) ;
34
36
37 // . . . . . Execution in Consol .......
38
39 //ENTER THE FIRST SEQUENCE 01 [ u s e s q u a r e b r a c k e t −
a r r a y form ]= [ 2 −1 2 3 1 ]
40
41 //ENTER THE s t a r t i n g p o i n t o f a r r a y = −2
42
43 // C r o s s C o r r e l a t i o n S e q u e n c e i s =
44
45 // 2. 5. 3. 5. 19. 5. 3. 5. 2.
35
Experiment: 10
1 // Experiment −10
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program To o b t a i n Z t r a n s f o r m u s i n g
SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 x = input ( ” N e g a t i v e s e q u e n c e c o e f f i c i e n t =” ) // [ 1 2 3
2 7]
12 T = input ( ” s a m p l i n g t i m e =” ) // 1
13 Xz = poly ([ x ] , ”Z” ,” c o e f f ” )
14 disp ( Xz , ’X( Z ) = ’ )
15 // For P o s i t i v e s e q u e n c e
36
16 z = poly (0 , ’ z ’ )
17 disp ( ” p o s i t i v e s e q u e n c e o f Z t r a n s f o r m =” )
18 Xzp = horner ( Xz ,1/ z )
19 disp ( Xzp , ’X( z ) ’ )
20
21 // D i s c r e a t form
22 disp ( ” T r a n s f e r F u n c t i o n i n S t a t e −s p a c e
r e p r e s e n t a t i o n = ”)
23 s = poly (0 , ’ s ’ ) ;
24 z = poly (0 , ’ z ’ ) ;
25 tf = syslin ( ’ c ’ ,( s +1) /( s ^2 -5* s +2) ) ;
26 disp ( tf )
27 disp ( ” T r a n s f e r F u n c t i o n i n D i s c r e t e form = ”)
28 df = horner ( tf ,(2/ T ) *( z -1) /( z +1) )
29 disp ( df )
30
31
32 // . . . . Execution Console . . . .
33
34 // N e g a t i v e e q u e n c e c o e f f i c i e n t = [ 1 , 2 , 3 , 2 , 7 ]
35 // s a m p l i n g t i m e =1
36
37 // X( Z ) =
38
39 // 2 3 4
40 // 1 + 2Z + 3Z + 2Z + 7Z
41
42 // p o s i t i v e s e q u e n c e c o e f f i c i e n t =
43
44 //X( z )
45
46 // 2 3 4
47 // 7 + 2z + 3z + 2z + z
48 // −−−−−−−−−−−−−−−−−−−−
49 // 4
50 // z
51
52 // T r a n s f e r F u n c t i o n i n S t a t e −s p a c e r e p r e s e n t a t i o n
37
Figure 10.1: Z transform
53 // =
54
55 // 1 + s
56 // −−−−−−−−−
57 // 2
58 // 2 − 5 s + s
59
60 // T r a n s f e r F u n c t i o n i n D i s c r e t e form =
61
62 // 2
63 // 0 . 2 5 − 0 . 5 z − 0 . 7 5 z
64 // −−−−−−−−−−−−−−−−−−−
65 // 2
66 // − 4 + z + z
38
Experiment: 11
1 // Experiment −11
2 // windows − 7 − 64− B i t
3 // S c i l a b − 5 . 4 . 1
4
5
6 //AIM : Devlop a program t o P l o t p o l e z e r o f r o
t r a n s f e r f u n c t i o n u s i n g SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 z = poly (0 , ’ z ’ ) ;
12 num = input ( ’ E n t e r Numerator e q u a t i o n = ’ ) // [ 1 ] ;
13 den = input ( ’ E n t e r D eno mina tor e q u a t i o n = ’ ) // [ 1 − 1 . 5 ∗ z
ˆ −1+0.5∗ z ˆ − 2 ] ;
14 tf = num ./ den
15 disp ( tf , ” T r a n s f e r F u n c t i o n w i t h p o s i t i v e power = ” )
39
Figure 11.1: Pole Zero form Transfer function
16 H = syslin ( ’ c ’ , tf ) ;
17 plzr ( H )
18 scf ;
19 bode ( H )
20
21 //−−−−− COnsole window−−−−
22 // E n t e r Numerator e q u a t i o n = [ 1 ]
23 // E n t e r Den omin ator e q u a t i o n =[1 −1.5∗ z ˆ −1+0.5∗ z ˆ −2]
24
25 // T r a n s f e r F u n c t i o n w i t h p o s i t i v e power =
26
27 // 2
28 // z
29 // −−−−−−−−−−−−−
30 // 2
31 // 0.5 − 1.5 z + z
40
Figure 11.2: Pole Zero form Transfer function
41
Experiment: 12
Develop a program to
understand the concept of
amplitude modulation.
1 // Experiment −12
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r P e r f o r m i n g A m p l i t u d e
m o d u l a t i o n u s i n g SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 f = input ( ” E n t e r t h e v a l u e o f s i g n a l f r e q u e n c y=” ) ;
// f =5
12 fc = input ( ” E n t e r t h e v a l u e o f c a r r i e r f r e q u e n c y=” ) ;
// ( f c >f ) f c = 100
42
Figure 12.1: Amplitude Modulation
13 n =0:1200;
14 t = n / fc ;
15 m = input ( ” E n t e r t h e v a l u e o f m o d u l a t i o n i n d e x =” ) ; //
m = 1
16 s1 = sin (2* %pi * f * t ) ;
17 subplot (311) ;
18 plot ( s1 ) ;
19 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
20 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
21 title ( ” A c t u a l s i g n a l ” ,” f o n t s i z e ” ,4) ;
22 // G e n e r a t i o n o f c a r r i e r s i g n a l
23 s2 =1+0.5* cos (2* %pi * m * t ) ;
24 subplot (312) ;
25 plot ( s2 ) ;
26 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
27 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
28 title ( ” C a r r i e r s i g n a l ” ,” f o n t s i z e ” ,4) ;
29 ms = s2 .* s1 ; // M o d u l a t i n g S i g n a l
30 subplot (313) ;
31 plot ( ms ) ;
32 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
33 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
43
34 title ( ” Modulated s i g n a l ” ,” f o n t s i z e ” ,4) ;
35
36 //−−− c o n s o l v a l u e −−−
37 // E n t e r t h e v a l u e o f s i g n a l f r e q u e n c y =5
38
39 // E n t e r t h e v a l u e o f c a r r i e r f r e q u e n c y =100
40
41 // E n t e r t h e v a l u e o f m o d u l a t i o n i n d e x =1
44
Experiment: 13
Develop a program to
understand the concept of
frequency modulation.
1 // Experiment −13
2 // windows − 7 − 64− B i t
3 // S c i l a b − 6 . 0 . 1
4
5
6 //AIM : Devlop a program f o r P e r f o r m i n g F r e q u e n c y
m o d u l a t i o n u s i n g SCILAB c o d e
7
8
9 clear ;
10 clc ;
11 t =0:0.0001:0.1;
12 vm = input ( ” E n t e r t h e v a l u e o f m o d u l a t i n g v o l a t g e =”
) ; // vm = 5
13 fm = input ( ” E n t e r t h e v a l u e o f m o d u l a t i n g f r e q u e n c y=”
45
Figure 13.1: Frequency Modulation
) ; // fm =25
14 vc = input ( ” E n t e r t h e v a l u e o f c a r r i e r v o l a t g e =” ) ;
// vc = 5
15 fc = input ( ” E n t e r t h e v a l u e o f c a r r i e r f r e q u e n c y=” ) ;
// ( f c >f ) f c = 400
16 m = input ( ” E n t e r t h e v a l u e o f m o d u l a t i o n i n d e x =” ) ; //
m = 5
17 // G e n e r a t i o n o f c a r r i e r s i g n a l
18 v1 = vc * sin (2* %pi * fc * t ) ;
19 subplot (312) ;
20 plot (t , v1 ) ;
21 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
22 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
23 title ( ” C a r r i e r wave ” ,” f o n t s i z e ” ,4) ;
24 // g e n e r a t i o n o f M o d u l a t i n g wave
25 v2 = vm * sin (2* %pi * fm * t ) ;
26 subplot (311) ;
27 plot (t , v2 ) ;
28 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
29 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
30 title ( ” M o d u l a t i n g wave ” ,” f o n t s i z e ” ,4) ;
31 vfm = 5*( sin (2* %pi * fc * t +( m .* sin (2* %pi * fm * t ) ) ) ) //
46
Modulating S i g n a l
32 subplot (313) ;
33 plot (t , vfm ) ;
34 xlabel ( ” Time ( s e c . )−−−−−>” ,” f o n t s i z e ” ,4) ;
35 ylabel ( ” Amplitude −−−−−>” ,” f o n t s i z e ” ,4) ;
36 title ( ” Modulated s i g n a l ” ,” f o n t s i z e ” ,4) ;
37
38 //−−− c o n s o l v a l u e −−−
39
40 // E n t e r t h e v a l u e o f m o d u l a t i n g v o l a t g e =5
41
42 // E n t e r t h e v a l u e o f m o d u l a t i n g f r e q u e n c y =25
43
44 // E n t e r t h e v a l u e o f c a r r i e r v o l a t g e =5
45
46 // E n t e r t h e v a l u e o f c a r r i e r f r e q u e n c y =400
47
48 // E n t e r t h e v a l u e o f m o d u l a t i o n i n d e x =5
47