Scilab Manual for Signals & Systems PDF

Document Details

N. K. Orchid College of Engineering & Technology, Solapur

2024

Prof Akhtar Nadaf

Tags

Scilab Signals and Systems Engineering Electronics and Telecommunication

Summary

This Scilab manual provides solutions and experiments for Signals and Systems, covering topics like signal generation and basic operations on continuous and discrete time signals. It's suitable for undergraduate students in Electronics and Telecommunication Engineering.

Full Transcript

Scilab Manual for Signals & Systems by Prof Akhtar Nadaf Electronics and Telecommunication Engineering N.K. Orchid College Of Engineering & Technology, Solapur1 Solutions provided by...

Scilab Manual for Signals & Systems by Prof Akhtar Nadaf Electronics and Telecommunication Engineering N.K. Orchid College Of Engineering & Technology, Solapur1 Solutions provided by Prof Akhtar Nadaf Electronics and Telecommunication Engineering N.k. Orchid College Of Engineering & Technology Solapur October 20, 2024 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 3 1 Generation of continuous & discrete time signals 5 2 Basic operations on CT & DT Signals 11 3 Determination of Even & odd part of signal 20 4 Determination of energy & power of signal 24 5 Sampling Theorem 26 6 Linear convolution sum and integral 29 7 Fourier series 33 8 Fourier transform 40 9 Laplace Transform 44 10 Z transform & Inverse Z transform 46 11 Response of LTI System 48 12 Probability 50 13 Auto correlation 52 14 Cross correlation 55 2 List of Experiments Solution 1.1 Generation of Continious Time Signals...... 5 Solution 1.2 Generation of Discrete Time signals........ 7 Solution 2.1 Basic Operation on CT Signals.......... 11 Solution 2.2 Basic Operation on CT Signals.......... 13 Solution 2.3 Basic Operatiion on DT Signals.......... 15 Solution 2.4 Basic Operation on DT Signals.......... 17 Solution 3.1 Determination of even and odd part of CT signal 20 Solution 3.2 Determination of even and odd part of DT signal 22 Solution 4.1 Determination of energy and power of CT signal. 24 Solution 5.1 Sampling Theorem................. 26 Solution 6.1 Linear convolution................. 29 Solution 6.2 Convolution Integral................ 30 Solution 7.1 Fourier Series of CT Signal............. 33 Solution 7.2 Fourier Series of DT Signal............. 35 Solution 8.1 Fourier Transform of CT Signal.......... 40 Solution 8.2 Discrete Time Fourier Transform......... 42 Solution 9.1 Laplace transform.................. 44 Solution 10.1 Z transform and Inverse Z transform of given se- quence........................ 46 Solution 12.1 Estimation of probability for tossing of coin... 50 Solution 13.1 Auto Correlation of DT signal........... 52 Solution 14.1 Cross correlation.................. 55 3 List of Figures 1.1 Generation of Continious Time Signals............ 7 1.2 Generation of Discrete Time signals.............. 10 2.1 Basic Operation on CT Signals................ 13 2.2 Basic Operation on CT Signals................ 15 2.3 Basic Operatiion on DT Signals................ 17 2.4 Basic Operation on DT Signals................ 19 3.1 Determination of even and odd part of CT signal...... 21 3.2 Determination of even and odd part of DT signal...... 23 5.1 Sampling Theorem....................... 28 6.1 Linear convolution....................... 31 6.2 Convolution Integral...................... 32 7.1 Fourier Series of CT Signal................... 36 7.2 Fourier Series of CT Signal................... 37 7.3 Fourier Series of CT Signal................... 37 7.4 Fourier Series of CT Signal................... 38 7.5 Fourier Series of DT Signal................... 39 8.1 Fourier Transform of CT Signal................ 41 8.2 Discrete Time Fourier Transform............... 43 11.1 Step Response of LTI System................. 49 11.2 Step Response of LTI System................. 49 13.1 Auto Correlation of DT signal................. 54 14.1 Cross correlation........................ 56 4 Experiment: 1 Generation of continuous & discrete time signals Scilab code Solution 1.1 Generation of Continious Time Signals 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : GENERATION OF CONTINUOUS TIME SIGNALS 4 //UNIT IMPULSE SIGNAL 5 clc ; 6 clear all ; 7 close ; 8 N =7; //SET LIMIT 9 t1 = -N : N ; 10 x1 =[ zeros (1 , N ) ,1 , zeros (1 , N ) ]; 11 subplot (2 ,3 ,1) ; 12 plot ( t1 , x1 ) ; 13 xgrid (4 ,1 ,7) ; // x g r i d ( [ c o l o r ] , [ t h i c k n e s s ] , [ s t y l e ] ) 14 xlabel ( ” Time ” ) ; 15 ylabel ( ” A m p l i t u d e ” ) ; 16 title ( ” U n i t I m p u l s e S i g n a l ” ) ; 17 18 //UNIT STEP SIGNAL 19 t2 =0:4; 5 20 x2 = ones (1 ,5) ; 21 subplot (2 ,3 ,2) ; 22 plot ( t2 , x2 ) ; 23 xgrid (4 ,1 ,7) ; 24 xlabel ( ” t i m e ” ) ; 25 ylabel ( ” a m p l i t u d e ” ) ; 26 title ( ” U n i t S t e p S i g n a l ” ) ; 27 28 //EXPONENTIAL SIGNAL 29 t3 =0:1:20; 30 x3 = exp ( - t3 ) ; 31 subplot (2 ,3 ,3) ; 32 plot ( t3 , x3 ) ; 33 xgrid (4 ,1 ,7) ; 34 xlabel ( ” t i m e ” ) ; 35 ylabel ( ” A m p l i t u d e ” ) ; 36 title ( ” E x p o n e n t i a l S i g n a l ” ) ; 37 38 //RAMP SIGNAL 39 t4 = -0:20; 40 x4 = t4 ; 41 subplot (2 ,3 ,4) ; 42 plot ( t4 , x4 ) ; 43 xgrid (4 ,1 ,7) ; 44 xlabel ( ” Time ” ) ; 45 ylabel ( ” A m p l i t u d e ” ) ; 46 title ( ”Ramp S i g n a l ” ) ; 47 48 //SINUSOIDAL SIGNAL 49 50 t5 =0:0.04:1; 51 x5 = sin (2* %pi * t5 ) ; 52 subplot (2 ,3 ,5) ; 53 plot ( t5 , x5 ) ; 54 xgrid (4 ,1 ,7) ; 55 title ( ” S i n u s o i d a l S I g n a l ” ) 56 xlabel ( ” Time ” ) ; 57 ylabel ( ” A m p l i t u d e ” ) ; 6 Figure 1.1: Generation of Continious Time Signals 58 59 //RANDOM SIGNAL 60 t6 = -10:1:20; 61 x6 = rand (1 ,31) ; 62 subplot (2 ,3 ,6) ; 63 plot ( t6 , x6 ) ; 64 xgrid (4 ,1 ,7) ; 65 xlabel ( ” Time ” ) ; 66 ylabel ( ” A m p l i t u d e ” ) ; 67 title ( ”Random S i g n a l ” ) ; Scilab code Solution 1.2 Generation of Discrete Time signals 1 //O. S. Windows 10 2 // S c i l a b 6. 0. 1 3 // C a p t i o n : G e n e r a t i o n o f D i s c r e t e time s i g n a l s 4 clear ; 5 clc ; 6 // DT U n i t s t e p S i g n a l 7 7 t =0:4; 8 y = ones (1 ,5) ; 9 subplot (3 ,2 ,1) ; 10 plot2d3 (t , y ) ; 11 xgrid (4 ,1 ,7) ; // x g r i d ( [ c o l o r ] , [ t h i c k n e s s ] , [ s t y l e ] ) 12 xlabel ( ” Time ” ) ; 13 xlabel ( ” n” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ”DT U n i t S t e p S i g n a l ”); 16 17 //DT U n i t Ramp s i g n a l 18 n1 =0:8; 19 // F i g u r e 1. 1 : Waveform g e n e r a t i o n u s i n g DT s i g n a l s 20 y1 = n1 ; 21 subplot (3 ,2 ,2) ; 22 plot2d3 ( n1 , y1 ) ; 23 xgrid (4 ,1 ,7) ; // x g r i d ( [ c o l o r ] , [ t h i c k n e s s ] , [ s t y l e ] ) 24 xlabel ( ” Time ” ) ; 25 xlabel ( ” n” ) ; 26 ylabel ( ” A m p l i t u d e ” ) ; 27 title ( ”DT U n i t Ramp” ) ; 28 29 //DT Growing E x p o n e n t i a l S i g n a l 30 n1 =0:8; 31 y1 = n1 ; 32 y2 = exp ( n1 ) ; 33 subplot (3 ,2 ,3) ; 34 plot2d3 ( n1 , y2 ) ; 35 xgrid (4 ,1 ,7) ; // x g r i d ( [ c o l o r ] , [ t h i c k n e s s ] , [ s t y l e ] ) 36 xlabel ( ” Time ” ) ; 37 xlabel ( ” n” ) ; 38 ylabel ( ” A m p l i t u d e ” ) ; 39 title ( ”DT Growing E x p o n e n t i a l s i g n a l ” ) ; 40 41 //DT D e c a y i n g e x p o n e n t i a l S i g n a l 42 n1 =0:8; 43 y1 = n1 ; 44 y2 = exp ( - n1 ) ; 8 45 subplot (3 ,2 ,4) ; 46 plot2d3 ( n1 , y2 ) ; 47 xgrid (4 ,1 ,7) ; 48 xlabel ( ” n” ) ; 49 ylabel ( ” A m p l i t u d e ” ) ; 50 title ( ”DT D e c a y i n g E x p o n e n t i a l S i g n a l ” ) ; 51 52 //DT S i n u s o i d a l s i g n a l 53 n1 =0:25; 54 y1 = n1 ; 55 y2 = sin ( n1 ) ; 56 subplot (3 ,2 ,5) ; 57 plot2d3 ( n1 , y2 ) ; 58 xgrid (4 ,1 ,7) ; 59 xlabel ( ” n” ) ; 60 ylabel ( ” A m p l i t u d e ” ) ; 61 title ( ”DT S i n u s o i d a l S i g n a l ” ) ; 62 63 //DT U n i t I m p u l s e s i g n a l 64 l =7; 65 n=-l:l; 66 x =[ zeros (1 , l ) ,1 , zeros (1 , l ) ]; 67 b = gca () ; 68 b. y_location = ” m i d d l e ” ; 69 subplot (3 ,2 ,6) ; 70 plot2d3 ( ” gnn ” ,n , x ) ; 71 xgrid (4 ,1 ,7) ; 72 a = gce () ; 73 a. children (1). thickness =5; 74 xtitle ( ”DT U n i t s a m p l e s e q u e n c e ” ) ; 75 xlabel ( ” n” ) ; 76 ylabel ( ” A m p l i t u d e ” ) ; 9 Figure 1.2: Generation of Discrete Time signals 10 Experiment: 2 Basic operations on CT & DT Signals Scilab code Solution 2.1 Basic Operation on CT Signals 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : BASIC OPERATION ON CONTINUOUS TIME SIGNALS 4 clc ; 5 clear all ; 6 close ; 7 // I n p u t CT S i g n a l 8 t = -2:1:2; 9 x =[1 ,1 ,0 ,1 ,0]; 10 subplot (2 ,3 ,1) ; 11 plot (t , x ) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” Time ” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ” I n p u t CT S i g n a l x ( t ) ” ) ; 16 17 // A m p l i t u d e S c a l i n g 18 a =2; // S c a l i n g f a c t o r 11 19 subplot (2 ,3 ,2) ; 20 plot (t , a * x ) ; 21 xgrid (4 ,1 ,7) ; 22 xlabel ( ” Time ” ) ; 23 ylabel ( ” A m p l i t u d e ” ) ; 24 title ( ” z ( t ) =2x ( t ) ” ) ; 25 26 // A m p l i t u d e S c a l i n g 27 a =0.5; // S c a l i n g f a c t o r 28 subplot (2 ,3 ,3) ; 29 plot (t , a * x ) ; 30 xgrid (4 ,1 ,7) ; 31 xlabel ( ” Time ” ) ; 32 ylabel ( ” A m p l i t u d e ” ) ; 33 title ( ” z ( t ) =0.5 x ( t ) ” ) ; 34 35 // Time r e v e r s a l 36 subplot (2 ,3 ,4) ; 37 plot ( -t , x ) ; 38 xgrid (4 ,1 ,7) ; 39 xlabel ( ” Time ” ) ; 40 ylabel ( ” A m p l i t u d e ” ) ; 41 title ( ” z ( t )=x(− t ) ” ) ; 42 43 // Time S h i f t i n g 44 subplot (2 ,3 ,5) ; 45 plot ( t +2 , x ) ; 46 xgrid (4 ,1 ,7) ; 47 xlabel ( ” Time ” ) ; 48 ylabel ( ” A m p l i t u d e ” ) ; 49 title ( ” z ( t )=x ( t +2) ” ) ; 50 51 // Time S h i f t i n g 52 subplot (2 ,3 ,6) ; 53 plot (t -2 , x ) ; 54 xgrid (4 ,1 ,7) ; 55 xlabel ( ” Time ” ) ; 56 ylabel ( ” A m p l i t u d e ” ) ; 12 Figure 2.1: Basic Operation on CT Signals 57 title ( ” z ( t )=x ( t −2) ” ) ; Scilab code Solution 2.2 Basic Operation on CT Signals 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : BASIC OPERATION ON CONTINUOUS TIME SIGNALS 4 clc ; 5 clear all ; 6 close ; 7 // I n p u t CT S i g n a l 8 t = -2:1:2; 9 x =[1 ,1 ,0 ,1 ,0]; 10 subplot (2 ,3 ,1) ; 11 plot (t , x ) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” Time ” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 13 15 title ( ” I n p u t CT S i g n a l x ( t ) ” ) ; 16 17 // Time S c a l i n g 18 a =2; // S c a l i n g f a c t o r 19 subplot (2 ,3 ,2) ; 20 plot ( a *t , x ) ; 21 xgrid (4 ,1 ,7) ; 22 xlabel ( ” Time ” ) ; 23 ylabel ( ” A m p l i t u d e ” ) ; 24 title ( ” y ( t )=x ( 2 ∗ t ) ” ) ; 25 26 // Time S c a l i n g 27 a =0.5; // S c a l i n g f a c t o r 28 subplot (2 ,3 ,3) ; 29 plot ( a *t , x ) ; 30 xgrid (4 ,1 ,7) ; 31 xlabel ( ” Time ” ) ; 32 ylabel ( ” A m p l i t u d e ” ) ; 33 title ( ” y ( t )=x ( 0. 5 ∗ t ) ” ) ; 34 35 // S i g n a l A d d i t i o n 36 // I n p u t S i g n a l y ( t ) 37 t2 = -2:1:2; 38 y =[1 ,1 ,0 ,1 ,1]; 39 subplot (2 ,3 ,4) ; 40 plot ( t2 , y ) ; 41 xgrid (4 ,1 ,7) ; 42 xlabel ( ” Time ” ) ; 43 ylabel ( ” A m p l i t u d e ” ) ; 44 title ( ” I n p u t s i g n a l y ( t ) ” ) ; 45 46 // S i g n a l a d d i t i o n 47 subplot (2 ,3 ,5) ; 48 plot (n , x + y ) ; 49 xgrid (4 ,1 ,7) ; 50 xlabel ( ” Time ” ) ; 51 ylabel ( ” A m p l i t u d e ” ) ; 52 title ( ” z ( t )= x ( t )+y ( t ) ” ) ; 14 Figure 2.2: Basic Operation on CT Signals 53 54 // S i g n a l s u b t r a c t i o n 55 subplot (2 ,3 ,6) ; 56 plot (n ,x - y ) ; 57 xgrid (4 ,1 ,7) ; 58 xlabel ( ” Time ” ) ; 59 ylabel ( ” A m p l i t u d e ” ) ; 60 title ( ” z ( t )=x ( t )−y ( t ) ” ) ; Scilab code Solution 2.3 Basic Operatiion on DT Signals 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : BASIC OPERATION ON DISCRETE TIME SIGNALS 4 clc ; 5 clear all ; 6 close ; 7 // I n p u t DT S i g n a l 8 n = -2:1:2; 15 9 x =[1 ,1 ,0 ,0.5 ,0.5]; 10 subplot (2 ,3 ,1) ; 11 plot2d3 (n ,x , style =[ color ( ” b l u e ” ) ]) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” n” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ” I n p u t DT S i g n a l x ( n ) ” ) ; 16 17 // A m p l i t u d e S c a l i n g 18 a =2; // S c a l i n g f a c t o r 19 subplot (2 ,3 ,2) ; 20 plot2d3 (n , a *x , style =[ color ( ” b l u e ” ) ]) ; 21 xgrid (4 ,1 ,7) ; 22 xlabel ( ” n” ) ; 23 ylabel ( ” A m p l i t u d e ” ) ; 24 title ( ” z ( n ) =2∗x ( n ) ” ) ; 25 26 // A m p l i t u d e S c a l i n g 27 a =0.5; // S c a l i n g f a c t o r 28 subplot (2 ,3 ,3) ; 29 plot2d3 (n , a *x , style =[ color ( ” b l u e ” ) ]) ; 30 xgrid (4 ,1 ,7) ; 31 xlabel ( ” n” ) ; 32 ylabel ( ” A m p l i t u d e ” ) ; 33 title ( ” z ( n ) =0.5∗ x ( n ) ” ) ; 34 35 // Time r e v e r s a l 36 subplot (2 ,3 ,4) ; 37 plot2d3 ( -n ,x , style =[ color ( ” b l u e ” ) ]) ; 38 xgrid (4 ,1 ,7) ; 39 xlabel ( ” n” ) ; 40 ylabel ( ” A m p l i t u d e ” ) ; 41 title ( ” z ( n )=x(−n ) ” ) ; 42 43 // Time S h i f t i n g 44 subplot (2 ,3 ,5) ; 45 plot2d3 ( n +2 ,x , style =[ color ( ” b l u e ” ) ]) ; 46 xgrid (4 ,1 ,7) ; 16 Figure 2.3: Basic Operatiion on DT Signals 47 xlabel ( ” n” ) ; 48 ylabel ( ” A m p l i t u d e ” ) ; 49 title ( ” z ( n )=x ( n+2) ” ) ; 50 51 // Time S h i f t i n g 52 subplot (2 ,3 ,6) ; 53 plot2d3 (n -2 ,x , style =[ color ( ” b l u e ” ) ]) ; 54 xgrid (4 ,1 ,7) ; 55 xlabel ( ” n” ) ; 56 ylabel ( ” A m p l i t u d e ” ) ; 57 title ( ” z ( n )=x ( n −2) ” ) ; Scilab code Solution 2.4 Basic Operation on DT Signals 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : BASIC OPERATION ON DISCRETE TIME SIGNALS 4 clc ; 5 clear all ; 17 6 close ; 7 // I n p u t DT S i g n a l 8 n = -2:1:2; 9 x =[1 ,1 ,0 ,0.5 ,0.5]; 10 subplot (2 ,3 ,1) ; 11 plot2d3 (n ,x , style =[ color ( ” b l u e ” ) ]) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” n” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ” I n p u t DT S i g n a l x ( n ) ” ) ; 16 17 18 // Time S c a l i n g 19 a =2; // S c a l i n g f a c t o r 20 subplot (2 ,3 ,2) ; 21 plot2d3 ( a *n ,x , style =[ color ( ” b l u e ” ) ]) ; 22 xgrid (4 ,1 ,7) ; 23 xlabel ( ” n” ) ; 24 ylabel ( ” A m p l i t u d e ” ) ; 25 title ( ” z ( n ) =2∗x ( n ) ” ) ; 26 27 // Time S c a l i n g 28 a =0.5; // S c a l i n g f a c t o r 29 subplot (2 ,3 ,3) ; 30 plot2d3 ( a *n ,x , style =[ color ( ” b l u e ” ) ]) ; 31 xgrid (4 ,1 ,7) ; 32 xlabel ( ” n” ) ; 33 ylabel ( ” A m p l i t u d e ” ) ; 34 title ( ” z ( n ) =0.5∗ x ( n ) ” ) ; 35 36 // S i g n a l A d d i t i o n 37 // I n p u t S i g n a l y ( n ) 38 n2 = -2:1:2; 39 y =[1 ,1 ,0 ,1 ,1]; 40 subplot (2 ,3 ,4) ; 41 plot2d3 ( n2 ,y , style =[ color ( ” b l u e ” ) ]) ; 42 xgrid (4 ,1 ,7) ; 43 xlabel ( ” n” ) ; 18 Figure 2.4: Basic Operation on DT Signals 44 ylabel ( ” A m p l i t u d e ” ) ; 45 title ( ” I n p u t DT s i g n a l y ( n ) ” ) ; 46 47 // S i g n a l a d d i t i o n 48 subplot (2 ,3 ,5) ; 49 plot2d3 (n , x +y , style =[ color ( ” b l u e ” ) ]) ; 50 xgrid (4 ,1 ,7) ; 51 xlabel ( ” n” ) ; 52 ylabel ( ” A m p l i t u d e ” ) ; 53 title ( ” z ( n )=x ( n )+y ( n ) ” ) ; 54 55 // S i g n a l s u b t r a c t i o n 56 subplot (2 ,3 ,6) ; 57 plot2d3 (n ,x -y , style =[ color ( ” b l u e ” ) ]) ; 58 xgrid (4 ,1 ,7) ; 59 xlabel ( ” n” ) ; 60 ylabel ( ” A m p l i t u d e ” ) ; 61 title ( ” z ( n )=x ( n )−y ( n ) ” ) ; 19 Experiment: 3 Determination of Even & odd part of signal Scilab code Solution 3.1 Determination of even and odd part of CT sig- nal 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : DETERMINATION OF EVEN & ODD PART OF CT SIGNAL 4 clc ; 5 clear all ; 6 close ; 7 // I n p u t CT S i g n a l 8 t = -2:1:2; 9 x =[1 ,1 ,0 ,1 ,0]; 10 subplot (2 ,3 ,1) ; 11 plot (t , x ) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” Time ” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ” I n p u t CT S i g n a l x ( t ) ” ) ; 16 c =3; 17 for j =1: length ( t ) 20 Figure 3.1: Determination of even and odd part of CT signal 18 i=n(j); 19 xe ( j ) =(1/2) *( x ( c + i ) + x (c - i ) ) ; 20 xo ( j ) =(1/2) *( x ( c + i ) -x (c - i ) ) ; 21 end 22 xe =[ xe (c -2) , xe (c -1) , xe ( c +0) , xe ( c +1) , xe ( c +2) ]; 23 xo =[ xo (c -2) , xo (c -1) , xo ( c +0) , xo ( c +1) , xo ( c +2) ]; 24 subplot (2 ,3 ,2) ; 25 plot (t , xe ) ; 26 xgrid (4 ,1 ,7) ; 27 xlabel ( ” Time ” ) ; 28 ylabel ( ” A m p l i t u d e ” ) ; 29 title ( ”Xe ( t ) =1/2[ x ( t )+x(− t ) ] ” ) ; 30 subplot (2 ,3 ,3) ; 31 plot (t , - xo ) ; 32 xgrid (4 ,1 ,7) ; 33 xlabel ( ” Time ” ) ; 34 ylabel ( ” A m p l i t u d e ” ) ; 35 title ( ”Xo ( t ) =1/2[ x ( t )−x(− t ) ] ” ) ; 21 Scilab code Solution 3.2 Determination of even and odd part of DT sig- nal 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : DETERMINATION OF EVEN & ODD PART OF DT SIGNAL 4 clc ; 5 clear all ; 6 close ; 7 // I n p u t DT S i g n a l 8 n = -2:1:2; 9 x =[ -2 ,1 ,2 , -1 ,3]; 10 subplot (2 ,3 ,1) ; 11 plot2d3 (n ,x , style =[ color ( ” b l u e ” ) ]) ; 12 xgrid (4 ,1 ,7) ; 13 xlabel ( ” n” ) ; 14 ylabel ( ” A m p l i t u d e ” ) ; 15 title ( ” I n p u t DT S i g n a l x ( t ) ” ) ; 16 c =3; 17 for j =1: length ( n ) 18 i=n(j); 19 xe ( j ) =(1/2) *( x ( c + i ) + x (c - i ) ) ; 20 xo ( j ) =(1/2) *( x ( c + i ) -x (c - i ) ) ; 21 end 22 xe =[ xe (c -2) , xe (c -1) , xe ( c +0) , xe ( c +1) , xe ( c +2) ]; // c a l c u l a t i o n o f even Part 23 xo =[ xo (c -2) , xo (c -1) , xo ( c +0) , xo ( c +1) , xo ( c +2) ]; // c c a l c u l a t i o n o f odd p a r t 24 subplot (2 ,3 ,2) ; 25 plot2d3 (n , xe , style =[ color ( ” b l u e ” ) ]) ; 26 xgrid (4 ,1 ,7) ; 27 xlabel ( ” n” ) ; 28 ylabel ( ” A m p l i t u d e ” ) ; 29 title ( ”Xe ( n ) =1/2[ x ( n )+x(−n ) ] ” ) ; 30 subplot (2 ,3 ,3) ; 31 plot2d3 (n , - xo , style =[ color ( ” b l u e ” ) ]) ; 32 xgrid (4 ,1 ,7) ; 22 Figure 3.2: Determination of even and odd part of DT signal 33 xlabel ( ” n” ) ; 34 ylabel ( ” A m p l i t u d e ” ) ; 35 title ( ”Xo ( n ) =1/2[ x ( n )−x(−n ) ] ” ) ; 23 Experiment: 4 Determination of energy & power of signal Scilab code Solution 4.1 Determination of energy and power of CT signal 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : DETERMINATION OF ENERGY & POWER OF SIGNAL 4 // C a l c u l a t e e n e r g y o f s i g n a l y ( t ) =5e ˆ( −5 t ) 5 clc ; 6 clear all ; 7 t =0:0.001:10; 8 y = 5* exp ( -5* t ) ; 9 E = integrate ( ’ ( 5 ∗ exp ( −5∗ t ) ) ˆ2 ’ , ’ t ’ ,0 ,2* %pi ) ; // Calculation of energy of s i g n a l 10 disp (E , ’ Energy o f g i v e n s i g n a l i n J o u l e s= ’ ) ; // Expected output : 2. 5 J o u l e s 11 // E x p e c t e d o u t p o t i n c o n s o l e 12 // Energy o f g i v e n s i g n a l i n J o u l e s= 13 // 2.5 14 // C a l c u l a t e power o f x ( t )=Aeˆ( −5 t ) 15 t =0:0.001:10; 16 y =5* exp ( -5* t ) ; 17 P = integrate ( ’ ( 5 ∗ exp ( −5∗ t ) ) ˆ2 ’ , ’ t ’ ,0 ,2* %pi ) /(2* %pi ) 24 ; 18 disp (P , ’ power o f t h e s i g n a l i n Watts =: ’ ) ; 19 // E x p e c t e d Output i n c o n s o l e 20 // power o f t h e s i g n a l i n Watts =: 21 // 0.3978874 25 Experiment: 5 Sampling Theorem Scilab code Solution 5.1 Sampling Theorem 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : S a m p l i n g Theorem 4 clc ; 5 clear all ; 6 t =0:0.01:100; 7 f =0.02; 8 x = sin (2* %pi * f * t ) ; 9 subplot (2 ,2 ,1) ; 10 plot (t , x ) ; 11 xgrid (4 ,1 ,7) ; 12 xlabel ( ” Time ” ) ; 13 ylabel ( ” A m p l i t u d e ” ) ; 14 title ( ”CT S i g n a l ” ) ; 15 // S a m p l i n g f r e q u e n c y l e s s t h a n t w i c e s o f i n p u t signal frequency 16 fs1 =0.002; 17 n =0:0.1:100; 18 x1 = sin (2* %pi * f * n / fs1 ) ; 19 subplot (2 ,2 ,2) ; 20 plot2d3 (n , x1 , style =[ color ( ” b l u e ” ) ]) ; 26 21 xlabel ( ” n” ) ; 22 ylabel ( ” A m p l i t u d e ” ) ; 23 xgrid (4 ,1 ,7) ; 24 title ( ” f s 2 f ” ) ; 27 Figure 5.1: Sampling Theorem 28 Experiment: 6 Linear convolution sum and integral Scilab code Solution 6.1 Linear convolution 1 // VERSION : S c i l a b : 6. 0. 1 2 // OS : WINDOWS 10 3 // CAPTION : C o n v o l u t i o n sum o f two s e q u e n c e s x ( n ) =[1 ,4 ,3 ,2] & h(n) =[1 ,3 ,2 ,1] 4 clc ; 5 clear all ; 6 clc ; 7 x =[1 4 3 2]; 8 t1 =0:1:3 9 subplot (2 ,3 ,1) ; 10 plot2d3 ( t1 ,x , style =[ color ( ” b l u e ” ) ]) ; 11 xgrid (4 ,1 ,7) ; 12 xlabel ( ” n” ) ; 13 ylabel ( ” A m p l i t u d e ” ) ; 14 title ( ” I n p u t DT S i g n a l x ( n ) ” ) ; 15 16 h =[1 3 2 1]; 17 t2 =0:1:3 18 subplot (2 ,3 ,2) ; 29 19 plot2d3 ( t2 ,h , style =[ color ( ” b l u e ” ) ]) ; 20 xgrid (4 ,1 ,7) ; 21 xlabel ( ” n” ) ; 22 ylabel ( ” A m p l i t u d e ” ) ; 23 title ( ” I n p u t DT S i g n a l h ( n ) ” ) ; 24 y = convol (x , h ) ; 25 disp (y , ” C o n v o l u t i o n sum o f t h e a b o v e two s e q u e n c e s i s : ”); 26 // E x p e c t e d o u t p u t i n c o n s o l e : 27 // C o n v o l u t i o n sum o f t h e a b o v e two s e q u e n c e s i s : 28 29 // 1. 7. 17. 20. 16. 7. 2. 30 31 l = length ( y ) ; 32 t3 =0: l -1; 33 subplot (2 ,3 ,3) ; 34 plot2d3 ( t3 ,y , style =[ color ( ” b l u e ” ) ]) ; 35 xgrid (4 ,1 ,7) ; 36 xlabel ( ” n” ) ; 37 ylabel ( ” A m p l i t u d e ” ) ; 38 title ( ” y ( n )=x ( n ) ∗ h ( n ) ” ) ; Scilab code Solution 6.2 Convolution Integral 1 // S c i l a b V e r s i o n : 6. 0. 1 2 //O. S : Windows 10 3 // C a p t i o n : C o n v o l u t i o n i n t e g r a l o f x ( t ) =( eˆ− a t ). u ( t ) and h ( t )=u ( t ) 4 clear ; 5 close ; 6 clc ; 7 T =10; 8 h = ones (1 , T ) ; 30 Figure 6.1: Linear convolution 9 N2 =0: length ( h ) -1; 10 a =0.5; 11 for t =1: T 12 x ( t ) = exp ( - a *( t -1) ) ; 13 end 14 N1 =0: length ( x ) -1; 15 y = conv (x , h ) -1; 16 N =0: length ( x ) + length ( h ) -2; 17 subplot (2 ,3 ,1) ; 18 plot ( N1 , x ) 19 xlabel ( ” t ” ) ; 20 ylabel ( ” A m p l i t u d e ” ) ; 21 xgrid (4 ,1 ,7) ; 22 title ( ” I n p u t s i g n a l x ( t ) =( eˆ− a t ). u ( t ) ” ) 23 subplot (2 ,3 ,2) ; 24 plot ( N2 , h ) ; 25 xlabel ( ” t ” ) ; 26 ylabel ( ” A m p l i t u d e ” ) ; 27 xgrid (4 ,1 ,7) ; 28 title ( ” I n p u t s i g n a l h ( t )=u ( t ) ” ) ; 29 subplot (2 ,3 ,3) ; 30 plot ( N (1: T ) ,y (1: T ) ) 31 xlabel ( ” t ” ) ; 31 Figure 6.2: Convolution Integral 32 ylabel ( ” A m p l i t u d e ” ) ; 33 title ( ” C o n v o l u t i o n I n t e g r a l y ( t )=x ( t ) h ( t ) ” ) ; 34 xgrid (4 ,1 ,7) ; 32 Experiment: 7 Fourier series Scilab code Solution 7.1 Fourier Series of CT Signal 1 // S c i l a b V r s i o n : 6. 0. 1 2 //O. S : Windows 10 3 // C a p t i o n : CTFS o f a p e r i o d i c s i g n a l x ( t ) 4 clear ; 5 close ; 6 clc ; 7 t = -3:0.01:3; 8 // t 1 = −%pi ∗ 4 : ( %pi ∗ 4 ) / 1 0 0 : %pi ∗ 4 ; 9 // t 2 =−%pi ∗ 6 : ( %pi ∗ 6 ) / 1 0 0 : %pi ∗ 6 ; 10 xot = ones (1 , length ( t ) ) ; 11 x1t = (1/2) * cos ( %pi *2* t ) ; 12 xot_x1t = xot + x1t ; 13 x2t = cos ( %pi *4* t ) ; 14 xot_x1t_x2t = xot + x1t + x2t ; 15 x3t = (2/3) * cos ( %pi *6* t ) ; 16 xt = xot + x1t + x2t + x3t ; 17 // 18 figure 19 a = gca () ; 20 a. y_location = ” o r i g i n ” ; 21 a. x_location = ” o r i g i n ” ; 33 22 a. data_bounds =[ -4 ,0;2 4]; 23 plot (t , xot ) 24 ylabel ( ’ t ’ ) 25 title ( ’ x o t =1 ’ ) 26 // 27 figure 28 subplot (2 ,1 ,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 a. data_bounds =[ -4 , -3;2 4]; 33 plot (t , x1t ) 34 ylabel ( ’ t ’ ) 35 title ( ’ x1 ( t ) =1/2∗ c o s ( 2 ∗ p i ∗ t ) ’ ) 36 subplot (2 ,1 ,2) 37 a = gca () ; 38 a. y_location = ” o r i g i n ” ; 39 a. x_location = ” o r i g i n ” ; 40 a. data_bounds =[ -4 ,0;2 4]; 41 plot (t , xot_x1t ) 42 ylabel ( ’ t ’ ) 43 title ( ’ xo ( t )+x1 ( t ) ’ ) 44 // 45 figure 46 subplot (2 ,1 ,1) 47 a = gca () ; 48 a. y_location = ” o r i g i n ” ; 49 a. x_location = ” o r i g i n ” ; 50 a. data_bounds =[ -4 , -2;4 2]; 51 plot (t , x2t ) 52 ylabel ( ’ t ’ ) 53 title ( ’ x2 ( t ) =c o s ( 4 ∗ p i ∗ t ) ’ ) 54 subplot (2 ,1 ,2) 55 a = gca () ; 56 a. y_location = ” o r i g i n ” ; 57 a. x_location = ” o r i g i n ” ; 58 a. data_bounds =[ -4 ,0;4 4]; 59 plot (t , xot_x1t_x2t ) 34 60 ylabel ( ’ t ’ ) 61 title ( ’ xo ( t )+x1 ( t )+x2 ( t ) ’ ) 62 // 63 figure 64 subplot (2 ,1 ,1) 65 a = gca () ; 66 a. y_location = ” o r i g i n ” ; 67 a. x_location = ” o r i g i n ” ; 68 a. data_bounds =[ -4 , -3;4 3]; 69 plot (t , x3t ) 70 ylabel ( ’ t ’ ) 71 title ( ’ x1 ( t ) =2/3∗ c o s ( 6 ∗ p i ∗ t ) ’ ) 72 subplot (2 ,1 ,2) 73 a = gca () ; 74 a. y_location = ” o r i g i n ” ; 75 a. x_location = ” o r i g i n ” ; 76 a. data_bounds =[ -4 , -3;4 3]; 77 plot (t , xt ) 78 ylabel ( ’ t ’ ) 79 title ( ’ x ( t )=xo ( t )+x1 ( t )+x2 ( t )+x3 ( t ) ’ ) Scilab code Solution 7.2 Fourier Series of DT Signal 1 // S c i l a b V e r s i o n : 6. 0. 1 2 //O. S : Windows 10 3 // C a p t i o n : 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 o f x [ n ]= s i n (Won) 35 Figure 7.1: Fourier Series of CT Signal 36 Figure 7.2: Fourier Series of CT Signal Figure 7.3: Fourier Series of CT Signal 37 Figure 7.4: Fourier Series of CT Signal 4 clear ; 5 close ; 6 clc ; 7 n = 0:0.01:5; 8 N = 5; 9 Wo = 2* %pi / N ; 10 xn = sin ( Wo * n ) ; 11 for k =0: N -2 12 C ( k +1 ,:) = exp ( - sqrt ( -1) * Wo * n.* k ) ; 13 a ( k +1) = xn * C ( k +1 ,:) ’/ length ( n ) ; 14 if ( abs ( a ( k +1) ) 0 4 clear ; 5 clc ; 6 close ; 7 // Analog S i g n a l 8 A =1; // A m p l i t u d e 9 Dt = 0.005; 10 t =0: Dt :10; 11 ht = exp ( - A * t ) ; 12 // Cont i n u o u s time F o u r i e r Transform 13 Wmax =2* %pi *1; // Analog F r e q u e n c y = 1Hz 14 K =4; 15 k =0:( K /1000) : K ; 16 W = k * Wmax / K ; 17 HW = ht * exp ( - sqrt ( -1) *t ’* W ) * Dt ; 18 HW_Mag = abs ( HW ) ; 19 W =[ - mtlb_fliplr ( W ) ,W (2:1001) ]; // Omega from Wmax t o Wmax 40 Figure 8.1: Fourier Transform of CT Signal 20 HW_Mag =[ mtlb_fliplr ( HW_Mag ) , HW_Mag (2:1001) ]; 21 // 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 22 subplot (1 ,2 ,1) ; 23 a = gca () ; 24 a. y_location = ” o r i g i n ” ; 25 plot (t , ht ) ; 26 xgrid (4 ,1 ,7) ; 27 xlabel ( ” Time ” ) ; 28 ylabel ( ” A m p l i t u d e ” ) ; 29 title ( ” I n p u t S i g n a l h ( t ) ” ) 30 // P l o t t i n g Magnitude R e s p o n s e o f CTS 31 subplot (1 ,2 ,2) ; 32 a = gca () ; 33 a. y_location = ” o r i g i n ” ; 34 plot (W , HW_Mag ) ; 35 xgrid (4 ,1 ,7) ; 36 xlabel ( ” F r e q u e n c y i n r e d / s e c ” ) ; 37 ylabel ( ” A m p l i t u d e ” ) ; 38 title ( ” F r e q u e n c y R e s p o n s e ” ) ; 41 Scilab code Solution 8.2 Discrete Time Fourier Transform 1 //O. S : Windows 10 2 // S c i l a b V e r s i o n : 6. 0. 1 3 // C a p t i o n : 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 o f x [ n ]= 1 , a b s ( n )

Use Quizgecko on...
Browser
Browser