Digital Signal P Ramesh Babu
January 10, 2017 | Author: Gagan Hy | Category: N/A
Short Description
Download Digital Signal P Ramesh Babu...
Description
Scilab Textbook Companion for Digital Signal Processing by P. Ramesh Babu1 Created by Mohammad Faisal Siddiqui B.Tech (pursuing) Electronics Engineering Jamia Milia Islamia College Teacher Dr. Sajad A. Loan, JMI, New D Cross-Checked by Santosh Kumar, IITB July 12, 2011
1 Funded
by a grant from the National Mission on Education through ICT, http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab codes written in it can be downloaded from the ”Textbook Companion Project” section at the website http://scilab.in
Book Description Title: Digital Signal Processing Author: P. Ramesh Babu Publisher: Scitech Publications (INDIA) Pvt. Ltd. Edition: 4 Year: 2010 ISBN: 81-8371-081-7
1
Scilab numbering policy used in this document and the relation to the above book. Exa Example (Solved example) Eqn Equation (Particular equation of the above book) AP Appendix to Example(Scilab Code that is an Appednix to a particular Example of 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 List of Scilab Codes
4
1 DISCRETE TIME SIGNALS AND LINEAR SYSTEMS
11
2 THE Z TRANSFORM
34
3 THE DISCRETE FOURIER TRANSFORM
59
4 THE FAST FOURIER TRANSFORM
79
5 INFINITE IMPULSE RESPONSE FILTERS
90
6 FINITE IMPULSE RESPONSE FILTERS
102
7 FINITE WORD LENGTH EFFECTS IN DIGITAL FILTERS 139 8 MULTIRATE SIGNAL PROCESSING
141
9 STATISTICAL DIGITAL SIGNAL PROCESSING
143
11 DIGITAL SIGNAL PROCESSORS
146
3
List of Scilab Codes Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
1.1 1.2 1.3.a 1.3.b 1.4.a 1.4.d 1.5.a 1.5.c 1.5.d 1.11 1.12 1.13 1.18 1.19 1.32.a 1.37 1.38 1.45 1.57.a 1.61 1.62 1.64.a 1.64.c 2.1 2.2 2.3 2.4 2.5
Continuous Time Plot and Discrete Time Plot Continuous Time Plot and Discrete Time Plot Evaluate the Summations . . . . . . . . . . . . Evaluate the Summations . . . . . . . . . . . . Check for Energy or Power Signals . . . . . . . Check for Energy or Power Signals . . . . . . . Determining Periodicity of Signal . . . . . . . . Determining Periodicity of Signal . . . . . . . . Determining Periodicity of Signal . . . . . . . . Stability of the System . . . . . . . . . . . . . Convolution Sum of Two Sequences . . . . . . Convolution of Two Signals . . . . . . . . . . . Cross Correlation of Two Sequences . . . . . . Determination of Input Sequence . . . . . . . . Plot Magnitude and Phase Response . . . . . . Sketch Magnitude and Phase Response . . . . . Plot Magnitude and Phase Response . . . . . . Filter to Eliminate High Frequency Component Discrete Convolution of Sequences . . . . . . . Fourier Transform . . . . . . . . . . . . . . . . Fourier Transform . . . . . . . . . . . . . . . . Frequency Response of LTI System . . . . . . . Frequency Response of LTI System . . . . . . . z Transform and ROC of Causal Sequence . . . z Transform and ROC of Anticausal Sequence . z Transform of the Sequence . . . . . . . . . . z Transform and ROC of the Signal . . . . . . z Transform and ROC of the Signal . . . . . . 4
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
11 13 14 14 15 15 16 18 19 21 21 22 22 23 24 24 26 27 29 29 30 31 31 34 34 35 36 36
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
2.6 2.7 2.8.a 2.9 2.10 2.11 2.13.a 2.13.b 2.13.c 2.13.d 2.16 2.17 2.19 2.20.a 2.22 2.23 2.34 2.35.a 2.35.b 2.38 2.40 2.41.a 2.41.b 2.41.c 2.45 2.53.a 2.53.b 2.53.c 2.53.d 2.54 2.58 3.1 3.2 3.3 3.4 3.7 3.9 3.11
Stability of the System . . . . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Sequence . . . . . . . z Transform Computation . . . . . . . . . z Transform of the Sequence . . . . . . . z Transform of Discrete Time Signals . . . z Transform of Discrete Time Signals . . . z Transform of Discrete Time Signals . . . z Transform of Discrete Time Signals . . . Impulse Response of the System . . . . . Pole Zero Plot of the Difference Equation Frequency Response of the System . . . . Inverse z Transform Computation . . . . Inverse z Transform Computation . . . . Causal Sequence Determination . . . . . . Impulse Response of the System . . . . . Pole Zero Plot of the System . . . . . . . Unit Sample Response of the System . . . Determine Output Response . . . . . . . Input Sequence Computation . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Signal . . . . . . . . . Pole Zero Pattern of the System . . . . . z Transform of the Sequence . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of the Signal . . . . . . . . . z Transform of Cosine Signal . . . . . . . Impulse Response of the System . . . . . DFT and IDFT . . . . . . . . . . . . . . DFT of the Sequence . . . . . . . . . . . 8 Point DFT . . . . . . . . . . . . . . . . IDFT of the given Sequence . . . . . . . . Plot the Sequence . . . . . . . . . . . . . Remaining Samples . . . . . . . . . . . . DFT Computation . . . . . . . . . . . . . 5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37 37 37 38 38 39 39 40 40 41 41 42 44 44 45 45 46 47 49 50 52 53 53 54 55 55 55 56 56 56 58 59 60 62 62 63 64 65
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
3.13 3.14 3.15 3.16 3.17 3.18 3.20 3.21 3.23.a 3.23.b 3.23.c 3.23.d 3.23.e 3.23.f 3.24 3.25 3.26 3.27.a 3.27.b 3.30 3.32 3.36 4.3 4.4 4.6 4.8 4.9 4.10 4.11 4.12 4.13 4.14 4.15 4.16.a 4.16.b 4.17 4.18 4.19
Circular Convolution . . . . . . . . . . . . . Circular Convolution . . . . . . . . . . . . . Determine Sequence x3 . . . . . . . . . . . Circular Convolution . . . . . . . . . . . . . Circular Convolution . . . . . . . . . . . . . Output Response . . . . . . . . . . . . . . . Output Response . . . . . . . . . . . . . . . Linear Convolution . . . . . . . . . . . . . . N Point DFT Computation . . . . . . . . . N Point DFT Computation . . . . . . . . . N Point DFT Computation . . . . . . . . . N Point DFT Computation . . . . . . . . . N Point DFT Computation . . . . . . . . . N Point DFT Computation . . . . . . . . . DFT of the Sequence . . . . . . . . . . . . 8 Point Circular Convolution . . . . . . . . Linear Convolution using DFT . . . . . . . Circular Convolution Computation . . . . . Circular Convolution Computation . . . . . Calculate value of N . . . . . . . . . . . . . Sketch Sequence . . . . . . . . . . . . . . . Determine IDFT . . . . . . . . . . . . . . . Shortest Sequence N Computation . . . . . Twiddle Factor Exponents Calculation . . . DFT using DIT Algorithm . . . . . . . . . DFT using DIF Algorithm . . . . . . . . . 8 Point DFT of the Sequence . . . . . . . . 4 Point DFT of the Sequence . . . . . . . . IDFT of the Sequence using DIT Algorithm 8 Point DFT of the Sequence . . . . . . . . 8 Point DFT of the Sequence . . . . . . . . DFT using DIT Algorithm . . . . . . . . . DFT using DIF Algorithm . . . . . . . . . 8 Point DFT using DIT FFT . . . . . . . . 8 Point DFT using DIT FFT . . . . . . . . IDFT using DIF Algorithm . . . . . . . . . IDFT using DIT Algorithm . . . . . . . . . FFT Computation of the Sequence . . . . . 6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
65 66 67 67 68 69 70 70 71 71 72 72 72 73 73 73 74 75 75 76 76 78 79 80 80 81 81 82 82 82 83 83 84 84 85 85 86 86
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
4.20 4.21 4.22 4.23 4.24 5.1 5.2 5.4 5.5 5.6 5.7 5.8 5.9 5.10 5.11 5.12 5.13 5.15 5.16 5.17 5.18 5.19 5.29 6.1 6.5 6.6 6.7 6.8 6.9.a 6.9.b 6.10 6.11 6.12 6.13.a 6.13.b 6.14.a 6.14.b 6.15
8 Point DFT by Radix 2 DIT FFT . . . . . . . . . . DFT using DIT FFT Algorithm . . . . . . . . . . . Compute X using DIT FFT . . . . . . . . . . . . . . DFT using DIF FFT Algorithm . . . . . . . . . . . 8 Point DFT of the Sequence . . . . . . . . . . . . . Order of the Filter Determination . . . . . . . . . . Order of Low Pass Butterworth Filter . . . . . . . . Analog Butterworth Filter Design . . . . . . . . . . Analog Butterworth Filter Design . . . . . . . . . . Order of Chebyshev Filter . . . . . . . . . . . . . . . Chebyshev Filter Design . . . . . . . . . . . . . . . . Order of Type 1 Low Pass Chebyshev Filter . . . . . Chebyshev Filter Design . . . . . . . . . . . . . . . . HPF Filter Design with given Specifications . . . . . Impulse Invariant Method Filter Design . . . . . . . Impulse Invariant Method Filter Design . . . . . . . Impulse Invariant Method Filter Design . . . . . . . Impulse Invariant Method Filter Design . . . . . . . Bilinear Transformation Method Filter Design . . . . HPF Design using Bilinear Transform . . . . . . . . Bilinear Transformation Method Filter Design . . . . Single Pole LPF into BPF Conversion . . . . . . . . Pole Zero IIR Filter into Lattice Ladder Structure . Group Delay and Phase Delay . . . . . . . . . . . . LPF Magnitude Response . . . . . . . . . . . . . . . HPF Magnitude Response . . . . . . . . . . . . . . . BPF Magnitude Response . . . . . . . . . . . . . . . BRF Magnitude Response . . . . . . . . . . . . . . . HPF Magnitude Response using Hanning Window . HPF Magnitude Response using Hamming Window . Hanning Window Filter Design . . . . . . . . . . . . LPF Filter Design using Kaiser Window . . . . . . . BPF Filter Design using Kaiser Window . . . . . . . Digital Differentiator using Rectangular Window . . Digital Differentiator using Hamming Window . . . Hilbert Transformer using Rectangular Window . . . Hilbert Transformer using Blackman Window . . . . Filter Coefficients obtained by Sampling . . . . . . 7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86 87 87 88 88 90 90 91 92 92 93 93 94 94 95 96 96 97 97 98 99 99 100 102 104 104 106 108 110 112 114 116 118 122 124 124 126 127
Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa Exa
6.16 6.17 6.18.a 6.18.b 6.19 6.20 6.21 6.28 6.29 7.2 7.14 8.9 8.10 9.7.a 9.7.b 9.8.a 9.8.b 11.3 11.5
Coefficients of Linear phase FIR Filter . . . . . . . BPF Filter Design using Sampling Method . . . . Frequency Sampling Method FIR LPF Filter . . . Frequency Sampling Method FIR LPF Filter . . . Filter Coefficients Determination . . . . . . . . . . Filter Coefficients using Hamming Window . . . . LPF Filter using Rectangular Window . . . . . . . Filter Coefficients for Direct Form Structure . . . . Lattice Filter Coefficients Determination . . . . . . Subtraction Computation . . . . . . . . . . . . . . Variance of Output due to AD Conversion Process Two Component Decomposition . . . . . . . . . . Two Band Polyphase Decomposition . . . . . . . . Frequency Resolution Determination . . . . . . . . Record Length Determination . . . . . . . . . . . . Smallest Record Length Computation . . . . . . . Quality Factor Computation . . . . . . . . . . . . Program for Integer Multiplication . . . . . . . . . Function Value Calculation . . . . . . . . . . . . .
8
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
128 128 129 130 131 133 135 137 138 139 139 141 142 143 144 144 145 146 146
List of Figures 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11
Continuous Time Plot and Discrete Time Plot . Continuous Time Plot and Discrete Time Plot . Determining Periodicity of Signal . . . . . . . . Determining Periodicity of Signal . . . . . . . . Determining Periodicity of Signal . . . . . . . . Plot Magnitude and Phase Response . . . . . . Sketch Magnitude and Phase Response . . . . . Plot Magnitude and Phase Response . . . . . . Filter to Eliminate High Frequency Component Frequency Response of LTI System . . . . . . . Frequency Response of LTI System . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
12 13 17 18 20 23 25 26 28 30 32
2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
Pole Zero Plot of the Difference Equation Frequency Response of the System . . . Impulse Response of the System . . . . . Pole Zero Plot of the System . . . . . . . Unit Sample Response of the System . . Determine Output Response . . . . . . . Pole Zero Pattern of the System . . . . . Impulse Response of the System . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
42 43 46 48 49 51 54 57
3.1 3.2 3.3
DFT of the Sequence . . . . . . . . . . . . . . . . . . . . . . Plot the Sequence . . . . . . . . . . . . . . . . . . . . . . . . Sketch Sequence . . . . . . . . . . . . . . . . . . . . . . . . .
60 63 77
6.1 6.2 6.3 6.4
LPF Magnitude Response HPF Magnitude Response BPF Magnitude Response BRF Magnitude Response
. . . .
. . . . 9
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . . . . . .
. . . .
. . . . . . . .
. . . .
. . . . . . . .
. . . .
. . . . . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
103 105 107 109
6.5 6.6 6.7 6.8 6.9 6.10 6.11 6.12 6.13 6.14 6.15 6.16 6.17 6.18
HPF Magnitude Response using Hanning Window . HPF Magnitude Response using Hamming Window Hanning Window Filter Design . . . . . . . . . . . LPF Filter Design using Kaiser Window . . . . . . BPF Filter Design using Kaiser Window . . . . . . Digital Differentiator using Rectangular Window . . Digital Differentiator using Hamming Window . . . Hilbert Transformer using Rectangular Window . . Hilbert Transformer using Blackman Window . . . Frequency Sampling Method FIR LPF Filter . . . . Frequency Sampling Method FIR LPF Filter . . . . Filter Coefficients Determination . . . . . . . . . . Filter Coefficients using Hamming Window . . . . . LPF Filter using Rectangular Window . . . . . . .
10
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
111 113 115 117 119 121 123 125 126 129 131 132 134 136
Chapter 1 DISCRETE TIME SIGNALS AND LINEAR SYSTEMS
Scilab code Exa 1.1 Continuous Time Plot and Discrete Time Plot 1 2
3 4 5 6 7 8 9 10 11 12 13 14 15
// Example 1 . 1 // S k e t c h t h e c o n t i n u o u s t i m e s i g n a l x ( t ) =2∗ exp (−2 t ) and a l s o i t s d i s c r e t e t i m e e q u i v a l e n t s i g n a l w i t h a sampling period T = 0.2 sec clear all ; clc ; close ; t =0:0.01:2; x1 =2* exp ( -2* t ) ; subplot (1 ,2 ,1) ; plot (t , x1 ) ; xlabel ( ’ t ’ ) ; ylabel ( ’ x ( t ) ’ ) ; title ( ’CONTINUOUS TIME PLOT ’ ) ; n =0:0.2:2; x2 =2* exp ( -2* n ) ; subplot (1 ,2 ,2) ; 11
Figure 1.1: Continuous Time Plot and Discrete Time Plot
12
Figure 1.2: Continuous Time Plot and Discrete Time Plot 16 17 18 19
plot2d3 (n , x2 ) ; xlabel ( ’ n ’ ) ; ylabel ( ’ x ( n ) ’ ) ; title ( ’DISCRETE TIME PLOT ’ ) ;
Scilab code Exa 1.2 Continuous Time Plot and Discrete Time Plot 1 2
// Example 1 . 2 // S k e t c h t h e c o n t i n u o u s t i m e s i g n a l x=s i n ( 7 ∗ t )+s i n ( 1 0 ∗ t ) and a l s o i t s d i s c r e t e t i m e e q u i v a l e n t s i g n a l with a sampling p e r i o d T = 0 . 2 s e c 13
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
clear all ; clc ; close ; t =0:0.01:2; x1 = sin (7* t ) + sin (10* t ) ; subplot (1 ,2 ,1) ; plot (t , x1 ) ; xlabel ( ’ t ’ ) ; ylabel ( ’ x ( t ) ’ ) ; title ( ’CONTINUOUS TIME PLOT ’ ) ; n =0:0.2:2; x2 = sin (7* n ) + sin (10* n ) ; subplot (1 ,2 ,2) ; plot2d3 (n , x2 ) ; xlabel ( ’ n ’ ) ; ylabel ( ’ x ( n ) ’ ) ; title ( ’DISCRETE TIME PLOT ’ ) ;
Scilab code Exa 1.3.a Evaluate the Summations 1 // Example 1 . 3 ( a ) 2 //MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM 3 // C a l c u l a t e F o l l o w i n g Summations 4 clear all ; 5 clc ; 6 close ; 7 syms n ; 8 X = symsum ( sin (2* n ) ,n ,2 , 2) ; 9 // D i s p l a y t h e r e s u l t i n command window 10 disp (X , ” The V a l u e o f summation comes o u t t o be : ” ) ;
Scilab code Exa 1.3.b Evaluate the Summations 14
1 // Example 1 . 3 ( b ) 2 //MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM 3 // C a l c u l a t e F o l l o w i n g Summations 4 clear all ; 5 clc ; 6 close ; 7 syms n ; 8 X = symsum ( %e ^(2* n ) ,n ,0 , 0) ; 9 // D i s p l a y t h e r e s u l t i n command window 10 disp (X , ” The V a l u e o f summation comes o u t t o be : ” ) ;
Scilab code Exa 1.4.a Check for Energy or Power Signals 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Example 1 . 4 ( a ) //MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM // Find Energy and Power o f Given S i g n a l s clear all ; clc ; close ; syms n N ; x =(1/3) ^ n ; E = symsum ( x ^2 , n ,0 , %inf ) ; // D i s p l a y t h e r e s u l t i n command window disp (E , ” Energy : ” ) ; p =(1/(2* N +1) ) * symsum ( x ^2 , n ,0 , N ) ; P = limit (p ,N , %inf ) ; disp (P , ” Power : ” ) ; // The Energy i s F i n i t e and Power i s 0 . T h e r e f o r e t h e g i v e n s i g n a l i s an Energy S i g n a l
Scilab code Exa 1.4.d Check for Energy or Power Signals 1
// Example 1 . 4 ( d ) 15
2 3 4 5 6 7 8 9 10 11 12 13 14 15
//MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM // Find Energy and Power o f Given S i g n a l s clear all ; clc ; close ; syms n N ; x = %e ^(2* n ) ; E = symsum ( x ^2 , n ,0 , %inf ) ; // D i s p l a y t h e r e s u l t i n command window disp (E , ” Energy : ” ) ; p =(1/(2* N +1) ) * symsum ( x ^2 , n ,0 , N ) ; P = limit (p ,N , %inf ) ; disp (P , ” Power : ” ) ; // The Energy andPower i s i n f i n i t e . T h e r e f o r e t h e g i v e n s i g n a l i s an n e i t h e r Energy S i g n a l n o r Power S i g n a l
Scilab code Exa 1.5.a Determining Periodicity of Signal 1 2 3 4 5 6 7 8 9 10 11 12 13
// Example 1 . 5 ( a ) //To D e t e r m i n e Whether Given S i g n a l i s P e r i o d i c o r not clear all ; clc ; close ; t =0:0.01:2; x1 = exp ( %i *6* %pi * t ) ; subplot (1 ,2 ,1) ; plot (t , x1 ) ; xlabel ( ’ t ’ ) ; ylabel ( ’ x ( t ) ’ ) ; title ( ’CONTINUOUS TIME PLOT ’ ) ; n =0:0.2:2; 16
Figure 1.3: Determining Periodicity of Signal
17
Figure 1.4: Determining Periodicity of Signal 14 x2 = exp ( %i *6* %pi * n ) ; 15 subplot (1 ,2 ,2) ; 16 plot2d3 (n , x2 ) ; 17 xlabel ( ’ n ’ ) ; 18 ylabel ( ’ x ( n ) ’ ) ; 19 title ( ’DISCRETE TIME PLOT ’ ) ; 20 // Hence Given S i g n a l i s P e r i o d i c w i t h N=1
Scilab code Exa 1.5.c Determining Periodicity of Signal 1
// Example 1 . 5 ( c ) 18
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//To D e t e r m i n e Whether Given S i g n a l i s P e r i o d i c o r not clear all ; clc ; close ; t =0:0.01:10; x1 = cos (2* %pi * t /3) ; subplot (1 ,2 ,1) ; plot (t , x1 ) ; xlabel ( ’ t ’ ) ; ylabel ( ’ x ( t ) ’ ) ; title ( ’CONTINUOUS TIME PLOT ’ ) ; n =0:0.2:10; x2 = cos (2* %pi * n /3) ; subplot (1 ,2 ,2) ; plot2d3 (n , x2 ) ; xlabel ( ’ n ’ ) ; ylabel ( ’ x ( n ) ’ ) ; title ( ’DISCRETE TIME PLOT ’ ) ; // Hence Given S i g n a l i s P e r i o d i c w i t h N=3
Scilab code Exa 1.5.d Determining Periodicity of Signal 1 2 3 4 5 6 7 8 9
// Example 1 . 5 ( d ) //To D e t e r m i n e Whether Given S i g n a l i s P e r i o d i c o r not clear all ; clc ; close ; t =0:0.01:50; x1 = cos ( %pi * t /3) + cos (3* %pi * t /4) ; subplot (1 ,2 ,1) ; plot (t , x1 ) ; 19
Figure 1.5: Determining Periodicity of Signal
20
10 xlabel ( ’ t ’ ) ; 11 ylabel ( ’ x ( t ) ’ ) ; 12 title ( ’CONTINUOUS TIME PLOT ’ ) ; 13 n =0:0.2:50; 14 x2 = cos ( %pi * n /3) + cos (3* %pi * n /4) ; 15 subplot (1 ,2 ,2) ; 16 plot2d3 (n , x2 ) ; 17 xlabel ( ’ n ’ ) ; 18 ylabel ( ’ x ( n ) ’ ) ; 19 title ( ’DISCRETE TIME PLOT ’ ) ; 20 // Hence Given S i g n a l i s P e r i o d i c w i t h N=24
Scilab code Exa 1.11 Stability of the System 1 // Example 1 . 1 1 2 //MAXIMA SCILAB TOOLBOX REQUIRED FOR THIS PROGRAM 3 // T e s t i n g S t a b i l i t y o f Given System 4 clear all ; 5 clc ; 6 close ; 7 syms n ; 8 x =(1/2) ^ n 9 X = symsum (x , n ,0 , %inf ) ; 10 // D i s p l a y t h e r e s u l t i n command window 11 disp (X , ” Summation i s : ” ) ; 12 disp ( ’ Hence Summation < i n f i n i t y . Given System i s
S t a b l e ’ );
Scilab code Exa 1.12 Convolution Sum of Two Sequences 1 2 3
// Example 1 . 1 2 // Program t o Compute c o n v o l u t i o n o f g i v e n s e q u e n c e s // x ( n ) =[3 2 1 2 ] , h ( n ) =[1 2 1 2 ] ; 21
4 5 6 7 8 9 10
clear all ; clc ; close ; x =[3 2 1 2]; h =[1 2 1 2]; y = convol (x , h ) ; disp ( y ) ;
Scilab code Exa 1.13 Convolution of Two Signals 1 2 3 4 5 6 7 8 9 10
// Example 1 . 1 3 // Program t o Compute c o n v o l u t i o n o f g i v e n s e q u e n c e s // x ( n ) =[1 2 1 1 ] , h ( n ) =[1 −1 1 − 1 ] ; clear all ; clc ; close ; x =[1 2 1 1]; h =[1 -1 1 -1]; y = convol (x , h ) ; disp ( round ( y ) ) ;
Scilab code Exa 1.18 Cross Correlation of Two Sequences 1 2 3 4 5 6 7 8 9
// Example 1 . 1 8 // Program t o Compute C r o s s − c o r r e l a t i o n sequences // x ( n ) =[1 2 1 1 ] , h ( n ) =[1 1 2 1 ] ; clear all ; clc ; close ; x =[1 2 1 1]; h =[1 1 2 1]; h1 =[1 2 1 1]; 22
of given
Figure 1.6: Plot Magnitude and Phase Response 10 y = convol (x , h1 ) ; 11 disp ( round ( y ) ) ;
Scilab code Exa 1.19 Determination of Input Sequence 1 // Example 1 . 1 9 2 //To f i n d i n p u t x ( n ) 3 // h ( n ) =[1 2 1 ] , y ( n ) =[1 5 10 11 8 4 1 ] 4 clear all ; 5 clc ; 6 close ; 7 z = %z ; 8 a = z ^6+5*( z ^(5) ) +10*( z ^(4) ) +11*( z ^(3) ) +8*( z ^(2) ) +4*( z
^(1) ) +1; 9 b = z ^6+2* z ^(5) +1* z ^(4) ; 10 x = ldiv (a ,b ,5) ; 11 disp (x , ” x ( n )=” ) ;
23
Scilab code Exa 1.32.a Plot Magnitude and Phase Response 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// Example 1 . 3 2 // Program t o P l o t Magnitude and Phase R e s p o n c e clear all ; clc ; close ; w = - %pi :0.01: %pi ; H =1+2* cos ( w ) +2* cos (2* w ) ; // c a l u c u l a t i o n o f Phase and Magnitude o f H [ phase_H , m ]= phasemag ( H ) ; Hm = abs ( H ) ; a = gca () ; subplot (2 ,1 ,1) ; a . y_location = ” o r i g i n ” ; plot2d ( w / %pi , Hm ) ; xlabel ( ’ F r e q u e n c y i n R a d i a n s ’ ) ylabel ( ’ a b s (Hm) ’ ) ; title ( ’MAGNITUDE RESPONSE ’ ) ; subplot (2 ,1 ,2) ; a = gca () ; a . x_location = ” o r i g i n ” ; a . y_location = ” o r i g i n ” ; plot2d ( w /(2* %pi ) , phase_H ) ; xlabel ( ’ F r e q u e n c y i n R a d i a n s ’ ) ; ylabel ( ’
View more...
Comments