signals and systems laboratory with matlab®

8
Signals and Systems Laboratory with MATLAB® Alex Palamides Anastasia Veloni @ CRC Press Taylor &. Francis Group Boca Raton London NewYork CRC Press is an imprint of the Taylor & Francis Group, an informa business

Upload: others

Post on 10-Nov-2021

15 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Signals and Systems Laboratory with MATLAB®

Signals and Systems Laboratory with MATLAB®

Alex Palamides

Anastasia Veloni

@ CRC Press Taylor &. Francis Group

Boca Raton London NewYork

CRC Press is an imprint of the Taylor & Francis Group, an informa business

Page 2: Signals and Systems Laboratory with MATLAB®

Contents

Preface xiii Authors xvii

1. Introduction to MATLAB 1 1.1 What Is MATLAB? 1 1.2 Working Environment 1 1.3 Getting Started 2

1.3.1 Simple Arithmetic Operations 3 1.3.2 Comments 3 1.3.3 The Variable ans 3 1.3.4 Priority of Operations 3 1.3.5 Constants 4 1.3.6 Built-in Functions 5 1.3.7 Variables 6 1.3.8 Format 7 1.3.9 Help in MATLAB 7

1.4 Memory Management 8 1.4.1 Commands s a v e - l o a d - e x i t - q u i t 9 1.4.2 The Command c l e a r 10

1.5 Commands d i a r y and c l c 10 1.6 Vectors 11

1.6.1 Row Vectors 11 1.6.2 Commands l e n g t h / s i z e 11 1.6.3 Addition/Subtraction 12 1.6.4 Multiplication, Division, and Power 13 1.6.5 Column Vectors 14 1.6.6 Dot Product of Two Vectors 14 1.6.7 Useful Commands 15

1.7 Matrices 16 1.7.1 Matrix Concatenation 17 1.7.2 Working with Matrices 17 1.7.3 Addition/Subtraction 19 1.7.4 Multiplication of Matrices 19

1.7.4.1 The Dot Product as a Special Case of Matrix Multiplication 21

1.7.5 Power of a Matrix 21 1.7.6 Inverse of a Matrix 22 1.7.7 Determinant of a Matrix 22 1.7.8 Division of Matrices 23 1.7.9 Transpose of a Matrix 24 1.7.10 Special Forms of Matrices 25 1.7.11 Useful Commands 26

1.8 Plotting with MATLAB 27 1.8.1 Plotting in Two Dimensions 27

V

Page 3: Signals and Systems Laboratory with MATLAB®

vi Contents

1.8.2 The Fig File 29 1.8.3 The Command l i n s p a c e 29 1.8.4 Plotting Several Functions in One Figure 30 1.8.5 Formatting a Figure 32 1.8.6 Plotting in Different Figures 34 1.8.7 Commands for Plotting 36 1.8.8 Plotting Discrete-Time Functions 38 1.8.9 Graph in Polar Coordinates 39 1.8.10 Piecewise Functions 39 1.8.11 Plotting in Three Dimensions 40

1.8.11.1 Plotting Curves in Three Dimensions 41 1.8.11.2 Plotting Surfaces in Three Dimensions 41

1.9 Complex Numbers 43 1.9.1 Useful Commands 43 1.9.2 Forms of Complex Numbers 44 1.9.3 Operations with Complex Numbers 45 1.9.4 Graph of Complex Numbers 46

1.10 M-Files 48 1.10.1 Scripts 48 1.10.2 Functions 51

1.11 Input/Output Commands 54 1.12 File Management 55 1.13 Logical/Relational Operators 57 1.14 Control Flow 58 1.15 Symbolic Variables 62

1.15.1 Differentiation of a Function 62 1.15.2 Integration of a Function 63 1.15.3 Summation of a Function 63 1.15.4 Rational Form 64 1.15.5 Solving Algebraic Equations 64 1.15.6 Solving Differential Equations 65 1.15.7 The Command subs 66

1.16 Polynomials 66 1.17 (Pseudo)Random Numbers 68 1.18 Solved Problems 69 1.19 Homework Problems 75

2. Signals 77 2.1 Categorization by the Variable Type 77

2.1.1 Continuous-Time Signals 77 2.1.2 Discrete-Time Signals 78 2.1.3 Digital Signals 79

2.2 Basic Continuous-Time Signals 81 2.2.1 Sinusoidal Signals 81 2.2.2 Exponential Signals 82 2.2.3 Complex Exponential Signals 83 2.2.4 Unit Step Function 84 2.2.5 Unit Impulse or Dirac Delta Function 89

Page 4: Signals and Systems Laboratory with MATLAB®

Contents vii

2.2.6 Ramp Function 93 2.2.7 Rectangular Pulse Function 96

2.3 Discrete-Time Signals 99 2.3.1 Unit Impulse Sequence 100 2.3.2 Unit Step Sequence 102 2.3.3 Real Exponential Sequence 104 2.3.4 Complex Exponential Sequence 105 2.3.5 Sinusoidal Sequence 109

2.4 Properties of Signals I l l 2.4.1 Periodic Signals I l l

2.4.1.1 Sum of Periodic Continuous-Time Signals 112 2.4.1.2 Construction of Periodic Signals 114

2.4.2 Causal Signals 118 2.4.3 Even and Odd Signals 119 2.4.4 Energy and Power Signals 121 2.4.5 Deterministic and Stochastic Signals 124

2.5 Transformations of the Time Variable for Continuous-Time Signals 126 2.5.1 Time Reversal or Reflection 126 2.5.2 Time Scaling 127 2.5.3 Time Shifting 129

2.6 Transformations of the Time Variable for Discrete-Time Signals 132 2.7 Solved Problems 135 2.8 Homework Problems 145

3. Systems 147 3.1 Systems Classification 147

3.1.1 Classification according to the Number of Inputs and Outputs 147 3.1.2 Continuous-Time and Discrete-Time Signals 151 3.1.3 Deterministic and Stochastic Systems 151

3.2 Properties of Systems 151 3.2.1 Causal and Noncausal Systems 151 3.2.2 Static (Memoryless) and Dynamic (with Memory) Systems 152 3.2.3 Linear and Nonlinear Systems 155 3.2.4 Time-Invariant and Time-Variant Systems 158 3.2.5 Invertible and Non-Invertible Systems 165

3.2.5.1 Construction of the Inverse System 166 3.2.6 Stable and Unstable Systems 167

3.3 Solved Problems 168 3.4 Homework Problems 176

4. Time Domain System Analysis 179 4.1 Impulse Response 179 4.2 Continuous-Time Convolution 179

4.2.1 Computation of Convolution 180 4.2.2 The Command conv 186 4.2.3 Deconvolution 188 4.2.4 Continuous-Time Convolution Examples 189

4.3 Convolution Properties 199

Page 5: Signals and Systems Laboratory with MATLAB®

viii Contents

4.4 Interconnections of Systems 202 4.5 Stability 206 4.6 Discrete-Time Convolution 208

4.6.1 The Unit Impulse Sequence as Input to a System 208 4.6.2 Computation of Discrete-Time Convolution 211 4.6.3 Discrete-Time Convolution Examples 219

4.7 Systems Described by Difference Equations 223 4.8 Filters 224

4.8.1 The Command f i l t e r 224 4.8.2 Infinite Impulse Response Filters 228 4.8.3 Finite Impulse Response Filters 232

4.9 Stability Criterion for Discrete-Time Systems 234 4.10 Systems Described by Differential Equations 235 4.11 Step Response of a System 236 4.12 Solved Problems 237 4.13 Homework Problems 245

5. Fourier Series 249 5.1 Orthogonality of Complex Exponential Signals 249 5.2 Complex Exponential Fourier Series 250 5.3 Trigonometric Fourier Series 253 5.4 Fourier Series in the Cosine with Phase Form 256 5.5 Plotting the Fourier Series Coefficients 258 5.6 Fourier Series of Complex Signals 263 5.7 Fourier Series of Periodic Signals 265 5.8 Line Spectra 270 5.9 Properties of Fourier Series 272

5.9.1 Linearity 272 5.9.2 Time Shifting 273 5.9.3 Time Reversal 275 5.9.4 Time Scaling 275 5.9.5 Signal Multiplication 276

5.10 Symmetry 277 5.10.1 Even Symmetry 277 5.10.2 Odd Symmetry 278

5.11 Parseval's Identity 280 5.12 Criterion for the Approximation of a Signal by a Fourier Series Expansion.... 281 5.13 Relationship between Complex Exponential and Trigonometric

Fourier Series Coefficients 283 5.14 Solved Problems 285 5.15 Homework Problems 297

6. Fourier Transform 301 6.1 Mathematical Definition 301 6.2 The Commands f o u r i e r and i f o u r i e r 302 6.3 Fourier Transform Pairs 304 6.4 Properties of Fourier Transform 305 6.5 Convolution in Time and Frequency 311

Page 6: Signals and Systems Laboratory with MATLAB®

6.6 Symmetry of the Real and Imaginary Parts of Fourier Transform 312 6.7 Parseval's Theorem 313 6.8 Autocorrelation and Cross-Correlation 314 6.9 Solved Problems 318 6.10 Homework Problems 324

7. Fourier Analysis of Discrete-Time Signals 327 7.1 Discrete-Time Fourier Transform 327 7.2 Properties of Discrete-Time Fourier Transform 329 7.3 Parseval's Theorem for Discrete-Time Fourier Transform 336 7.4 Discrete Fourier Transform 336 7.5 Properties of Discrete Fourier Transform 339 7.6 Inverse Discrete Fourier Transform 341 7.7 Circular Shift of a Sequence 342

7.7.1 Discrete Fourier Transform of a Circularly Shifted Sequence 346 7.8 Circular Convolution 347

7.8.1 Discrete Fourier Transform of Circular Convolution 351 7.8.2 Relationship between Linear and Circular Convolution 352

7.9 Fast Fourier Transform 353 7.10 Relationship between DFT and DTFT 357 7.11 Relationship between Fourier Transform and Discrete Fourier Transform.... 360 7.12 Linear Convolution Computation via Fast Fourier Transform 361 7.13 Solved Problems 362 7.14 Homework Problems 370

8. Frequency Response 373 8.1 Continuous-Time Frequency Response 373 8.2 The Command f r e q s 376

8.2.1 The Command invf r e q s 381 8.3 The Command l s i m 383 8.4 System Response to Sinusoidal Input 384 8.5 Ideal Filters 389 8.6 Frequency Response of Discrete-Time Systems 394 8.7 The Command f r e q z 396

8.7.1 The Command invf r e q z 397 8.8 System Response to Discrete-Time Sinusoidal Input 399 8.9 Moving Average Filter 399 8.10 Solved Problems 401 8.11 Homework Problems 411

9. Laplace Transform 415 9.1 Mathematical Definition 415 9.2 Commands l a p l a c e and i l a p l a c e 416 9.3 Region of Convergence 419 9.4 Laplace Transform Pairs 420 9.5 Laplace Transform Properties and Theorems 421 9.6 Partial Fraction Expansion of a Rational Function 425

9.6.1 The Command r e s i d u e 429

Page 7: Signals and Systems Laboratory with MATLAB®

x Contents

9.7 Convolution in Time and in Complex Frequency 432 9.7.1 Convolution in the Time Domain 432 9.7.2 Convolution in the Complex Frequency Domain 433

9.8 Using the Laplace Transform to Solve Differential Equations 433 9.9 Solved Problems 436 9.10 Homework Problems 441

10. z-Transform 443 10.1 Mathematical Definition 443 10.2 Commands z t r a n s and i z t r a n s 444 10.3 Region of Convergence 446 10.4 z-Transform Pairs 446 10.5 Properties of z-Transform 447 10.6 Partial Fraction Expansion of a Rational Function 453

10.6.1 Commands r e s i d u e and r e s i d u e z 455 10.7 Using the z-Transform to Solve Difference Equations 457 10.8 Solved Problems 460 10.9 Homework Problems 467

11. Transfer Function 471 11.1 Continuous-Time Systems 471 11.2 The t f Command 473 11.3 Stability of Continuous-Time Systems 475 11.4 Transfer Function in Zero/Pole/Gain Form 477 11.5 Interconnections of Systems 478 11.6 Continuous-Time System Response 481 11.7 Discrete-Time Systems 485 11.8 The Command t f for Discrete-Time Systems 486 11.9 Stability of Discrete-Time Systems 486 11.10 Discrete-Time System Response 489

11.10.1 Step Response 489 11.10.2 Impulse Response 491 11.10.3 The Command d l s i m 493

11.11 Conversion between Continuous-Time and Discrete-Time Systems 494 11.12 Transfer Function and Frequency Response 495 11.13 Bode Plot 498 11.14 State-Space Representation 499

11.14.1 Construction of a State-Space Model 503 11.14.2 Discrete-Time State-Space Models 506

11.15 Solved Problems 508 11.16 Homework Problems 518

12. Suggested Laboratory Exercises 523 12.1 Laboratory 1: Introduction to MATLAB 523 12.2 Laboratory 2: Signals 524 12.3 Laboratory 3: Systems 525 12.4 Laboratory 4: Time Domain System Analysis 525 12.5 Laboratory 5: Fourier Series 526 12.6 Laboratory 6: Fourier Transform 527

Page 8: Signals and Systems Laboratory with MATLAB®

Contents xi

12.7 Laboratory 7: Fourier Analysis of Discrete-Time Systems 528 12.8 Laboratory 8: Frequency Response 528 12.9 Laboratory 9: Laplace Transform 529 12.10 Laboratory 10: z-Transform 530 12.11 Laboratory 11: Transfer Function 531

Appendix A: Signal Crossword 533

Appendix B: Notation 535

Bibliography 537

Index 539