EE 350 Continuous-Time Linear Systems Recitation 2 Recitation 2. 1
Recitation 2 Topics MATLAB Programming Vector Manipulation Built-in Housekeeping Functions Solved Problems Classification of Signals Basic Signal Operations Recitation 2. 2
Vector Manipulation Elements are accessed by specifying an index ranging from 1 to the number of elements in the vector Display elements 2 through 3 of vector >> x = [2, 4, 6, 8]; >> x(2:3) ans = 4 6 Delete elements 2 through 3 >> x = [2, 4, 6, 8]; >> x(2:3) = [] ans = 2 8 Recitation 2. 3
Vector Manipulation Display the last two elements of the vector x >> x = [2, 4, 6, 8]; >> x(end-1 : end) ans = 6 8 Display every other element starting with the first element of x >> x = [2, 4, 6, 8]; >> x(1 : 2 : end) ans = 2 6 Recitation 2. 4
Vector Functions in MATLAB Operation length of vector x; returns the number of elements Function length(x) size of vector x; returns the number of rows and columns size(x) transpose of x x largest element in x max(x) smallest element in x min(x) sum of elements in vector x sum(x) indices of nonzero elements find(x) indices of elements in a specified range find(x>3) first n indices corresponding to the nonzero elements in x find(x, n) Last n indices corresponding to the nonzero elements in x find(x, n, last ) Recitation 2. 5
Problem 1 For the vector x = -4 : 2 : 10, use MATLAB to determine 1. length(x) 2. size(x) 3. x 4. size(x ) 5. min(x) 6. max(x) 7. sum(x) 8. find(x) 9. find(x < 0) 10. find(x,3) 11. find(x,3, last ) Recitation 2. 6
Housekeeping Functions Operation lists variables currently in the workspace lists variables currently in the workspace with their size clear all variables from the workspace clear command window, cursor moves to the top clear the current figure window close the current figure window close all the figure windows Function who whos clear clc clf close close all Recitation 2. 7
Problem 2 The response of system to a unit-step input is often characterized by the rise-time, which is the time for the output to rise from 10% to 90% of its final value Write an m-file that determines the rise-time of t yt () 1 e t 0 Recitation 2. 8
Problem 2 The m-file must Clear the workspace and command window, and close open figures Generate a time vector t of 1000 points uniformly spaced between 0 and 10 Generate a vector y whose elements represent the values of the response at the time instants in t Numerically determine the rise-time using find Plot y versus t, and in the legend, specify the rise-time use the strcat and num2str functions Recitation 2. 9
Problem 2 Recitation 2. 10
Problem 2 Recitation 2. 11
Problem 3 Consider the signal t f() t eu( t) 1. Sketch f(t) 2. Classify f(t) as a causal or noncausal signal 3. Is f(t) either an even or odd function? 4. Is f(t) periodic or aperiodic? 5. Is f(t) an energy signal? If so, determine the energy metric E f 6. What is P f, the power of the signal f(t)? Recitation 2. 12
Problem 3 Solution Recitation 2. 13
Problem 3 Solution Recitation 2. 14
Problem 3 Solution Recitation 2. 15
Problem 4 Consider the signal n f( t) 5 u( t 10n 2) u(t 10n 2) n 1. Sketch f(t) 2. Classify f(t) as a causal or noncausal signal 3. Is f(t) either an even or odd function? 4. Is f(t) periodic or aperiodic? If periodic, what is the fundamental period? 5. Is f(t) an energy signal? If so, determine the energy metric E f 6. Is f(t) a power signal? If so, determine the power metric P f Recitation 2. 16
Problem 4 Solution Recitation 2. 17
Problem 4 Solution Recitation 2. 18
Problem 4 Solution Recitation 2. 19
Problem 5 Express the signal f(t) as the sum of even and odd functions f t e u t f t f t -t () () e() o() where f() t f( t) f() t f( t) fe( t) and fo( t) 2 2 1. Verify, for an arbitrary f(t), that the functions f e (t) and f o (t) are even and odd functions, respectively 2. Determine expressions for f e (t) and f o (t) for the given f(t) 3. Sketch f(t), f e (t) and f o (t) Recitation 2. 20
Problem 5 Solution Recitation 2. 21
Problem 5 Solution Recitation 2. 22
Problem 5 Solution Recitation 2. 23
Problem 6 Consider the signal shown below f () t 1 1 0 1 t 1. Find an expression for f(t) 2. Sketch the following signals: f(t-1), 2f(t+1), f(t/3), f(-t), f(1-t) Recitation 2. 24
Problem 6 Solution Recitation 2. 25
Problem 6 Solution Recitation 2. 26
Problem 6 Solution Recitation 2. 27
EE 350 Continuous-Time Linear Systems Recitation 2 Recitation 2. 1
Recitation 2 Topics MATLAB Programming Vector Manipulation Built-in Housekeeping Functions Solved Problems Classification of Signals Basic Signal Operations Recitation 2. 2
Vector Manipulation Elements are accessed by specifying an index ranging from 1 to the number of elements in the vector Display elements 2 through 3 of vector Delete elements 2 through 3 Recitation 2. 3
Vector Manipulation Display the last two elements of the vector x Display every other element starting with the first element of x Recitation 2. 4
Vector Functions in MATLAB Operation length of vector x; returns the number of elements Function length(x) size of vector x; returns the number of rows and columns size(x) transpose of x x largest element in x max(x) smallest element in x min(x) sum of elements in vector x sum(x) indices of nonzero elements find(x) indices of elements in a specified range find(x>3) first n indices corresponding to the nonzero elements in x find(x, n) Last n indices corresponding to the nonzero elements in x find(x, n, last ) Recitation 2. 5
Problem 1 For the vector x = -4 : 2 : 10, use MATLAB to determine 1. length(x) 2. size(x) 3. x 4. size(x ) 5. min(x) 6. max(x) 7. sum(x) 8. find(x) 9. find(x < 0) 10. find(x,3) 11. find(x,3, last ) Recitation 2. 6
Housekeeping Functions Operation lists variables currently in the workspace lists variables currently in the workspace with their size clear all variables from the workspace clear command window, cursor moves to the top clear the current figure window close the current figure window close all the figure windows Function who whos clear clc clf close close all Recitation 2. 7
Problem 2 The response of system to a unit-step input is often characterized by the rise-time, which is the time for the output to rise from 10% to 90% of its final value Write an m-file that determines the rise-time of Recitation 2. 8
Problem 2 The m-file must Clear the workspace and command window, and close open figures Generate a time vector t of 1000 points uniformly spaced between 0 and 10 Generate a vector y whose elements represent the values of the response at the time instants in t Numerically determine the rise-time using find Plot y versus t, and in the legend, specify the rise-time use the strcat and num2str functions Recitation 2. 9
Problem 2 Recitation 2. 10
Problem 2 Recitation 2. 11
Problem 3 Consider the signal 1. Sketch f(t) 2. Classify f(t) as a causal or noncausal signal 3. Is f(t) either an even or odd function? 4. Is f(t) periodic or aperiodic? 5. Is f(t) an energy signal? If so, determine the energy metric E f 6. What is P f, the power of the signal f(t)? Recitation 2. 12
Problem 3 Solution Recitation 2. 13
Problem 3 Solution Recitation 2. 14
Problem 3 Solution Recitation 2. 15
Problem 4 Consider the signal 1. Sketch f(t) 2. Classify f(t) as a causal or noncausal signal 3. Is f(t) either an even or odd function? 4. Is f(t) periodic or aperiodic? If periodic, what is the fundamental period? 5. Is f(t) an energy signal? If so, determine the energy metric E f 6. Is f(t) a power signal? If so, determine the power metric P f Recitation 2. 16
Problem 4 Solution Recitation 2. 17
Problem 4 Solution Recitation 2. 18
Problem 4 Solution Recitation 2. 19
Problem 5 Express the signal f(t) as the sum of even and odd functions 1. Verify, for an arbitrary f(t), that the functions f e (t) and f o (t) are even and odd functions, respectively 2. Determine expressions for f e (t) and f o (t) for the given f(t) 3. Sketch f(t), f e (t) and f o (t) Recitation 2. 20
Problem 5 Solution Recitation 2. 21
Problem 5 Solution Recitation 2. 22
Problem 5 Solution Recitation 2. 23
Problem 6 Consider the signal shown below 1. Find an expression for f(t) 2. Sketch the following signals: f(t-1), 2f(t+1), f(t/3), f(-t), f(1-t) Recitation 2. 24
Problem 6 Solution Recitation 2. 25
Problem 6 Solution Recitation 2. 26
Problem 6 Solution Recitation 2. 27