EE 350 Continuous-Time Linear Systems Recitation 1 Recitation 1. 1
Recitation 1 Topics MATLAB Programming Basic Operations, Built-In Functions, and Variables m-files Graphics: 2D plots EE 210 Review Branch Relationships for Inductors and Capacitors Switched RC Circuits Switched RLC Circuits Recitation 1. 2
MATLAB MATLAB (matrix laboratory) is a numerical computing environment and programming language MATLAB allows Matrix manipulations Plotting Implementation of algorithms Symbolic computing Creation of user interfaces Recitation 1. 3
SIMULINK A dataflow graphical programming language for modeling and simulating dynamic systems Widely used in control systems engineering and signal processing Tightly integrated with the MATLAB environment Recitation 1. 4
Basic Operations MATLAB supports basic operations and can be used as a calculator Operation MATLAB Example Result addition 200 + 350 550 subtraction 300-200 100 multiplication 4*16 64 division 24/6 4 power 4^2 16 Recitation 1. 5
Built-In Functions There are a host of useful functions Operation MATLAB Result Example natural logarithm log(10) 2.3026 logarithm Base 10 log10(10) 1 exponent (e x ) exp(1) 2.7183 square root sqrt(100) 10 cos (radians) cos(pi) -1 cosd (degrees) cosd(45) 0.7071 To learn about a function xyz, type: >> help xyz Recitation 1. 6
Variables MATLAB does not require any variable type declarations or dimension statements to define variables When defining a variable, it must appear on the left side of the equality sign acceptable: >> x = 3 unacceptable: >> 3 = x Multiplication must be explicit, that is, include the multiplication symbol * acceptable: >> y = 3*x + 2 unacceptable: >> y = 3x + 2 Recitation 1. 7
Problem 1 Use Euler's identity to determine the rectangular form of x j 4 e Verify your result using the MATLAB command window MATLAB recognizes i and j as the square root of -1 Use 1i to improve calculation speed Recitation 1. 8
Vectors Row vector: >> w = [1, 2, 3, 4] Column vector: >> x = [1; 2; 3; 4] Row Vector of 5 ones: >> y = ones(1,5) Column vector of 5 ones: >> x = ones(5,1) Row vector of 3 zeros: >> a = zeros(1,3) A vector [1, 1.5, 2]: >> b = [1 : 0.5 : 2] A row vector of 100 points evenly spaced between 0 and 10: >> c = linspace(0,10); The semicolon suppresses the echo! Recitation 1. 9
Scripts MATLAB statements may be executed in a script as control flow program Generate a script by choosing New Script (Ctrl + N) Recitation 1. 10
Problem 2 Write a script that plots cos(t) and sin(t) versus t using 100 points uniformly distributed over the interval 0 to 4 Plot the cosine signal using a solid black curve, and the sine signal using a dotted blue curve Use the legend command to distinguish the curves in the plot Use the xlabel, ylabel, and title commands to label the plot Recitation 1. 11
Problem 3(A) Consider the capacitor shown below i( t) C vt () 1. What is i(t) in terms of v(t)? 2. What is the energy stored in the capacitor? 3. What is v(t) in terms of i(t)? 4. Can v(t) change instantaneously? Why? 5. Can i(t) change instantaneously? Recitation 1. 12
Problem 3(A) Solution Recitation 1. 13
Problem 3(A) Solution Recitation 1. 14
Problem 3(B) Consider the inductor shown below i( t) L vt () 1. What is v(t) in terms of i(t)? 2. What is the energy stored in the inductor? 3. What is i(t) in terms of v(t)? 4. Can i(t) change instantaneously? Why? 5. Can v(t) change instantaneously? Recitation 1. 15
Problem 3(B) Solution Recitation 1. 16
Problem 3(B) Solution Recitation 1. 17
Problem 4 Consider the RC circuit below, where the switched has been opened a long time before it is closed at time t = 0. 60V 5k 10k t 0 10k i( t) 250 F 1. Determine v(0 ) and i(0 ) 2. Determine v(0 + ) and i(0 + ) 3. Determine v( ) and i( ) 4. Obtain an ODE that describes the response of v(t) for t 0 Recitation 1. 18 vt ()
Problem 4 Solution Recitation 1. 19
Problem 4 Solution Recitation 1. 20
Problem 4 Solution Recitation 1. 21
Problem 4 Solution Recitation 1. 22
Problem 4 Solution Recitation 1. 23
Problem 5 Consider the RLC circuit below, where the switched has been closed a long time before it is opened at time t = 0. i( t) 2F 1H 1 2V t 0 1 1. Obtain an ODE that describes the response of i(t) for t 0. 2. Determine the initial conditions, i(t) and di/dt at time t = 0 +. 3. Determine i(t) after the switch has been opened a long time. Recitation 1. 24
Problem 5 Solution Recitation 1. 25
Problem 5 Solution Recitation 1. 26
Problem 5 Solution Recitation 1. 27
Problem 5 Solution Recitation 1. 28
EE 350 Continuous-Time Linear Systems Recitation 1 Recitation 1. 1
Recitation 1 Topics MATLAB Programming Basic Operations, Built-In Functions, and Variables m-files Graphics: 2D plots EE 210 Review Branch Relationships for Inductors and Capacitors Switched RC Circuits Switched RLC Circuits Recitation 1. 2
MATLAB MATLAB (matrix laboratory) is a numerical computing environment and programming language MATLAB allows Matrix manipulations Plotting Implementation of algorithms Symbolic computing Creation of user interfaces Recitation 1. 3
SIMULINK A dataflow graphical programming language for modeling and simulating dynamic systems Widely used in control systems engineering and signal processing Tightly integrated with the MATLAB environment Recitation 1. 4
Basic Operations MATLAB supports basic operations and can be used as a calculator Operation MATLAB Example Result addition 200 + 350 550 subtraction 300-200 100 multiplication 4*16 64 division 24/6 4 power 4^2 16 Recitation 1. 5
Built-In Functions There are a host of useful functions Operation MATLAB Result Example natural logarithm log(10) 2.3026 logarithm Base 10 log10(10) 1 exponent (e x ) exp(1) 2.7183 square root sqrt(100) 10 cos (radians) cos(pi) -1 cosd (degrees) cosd(45) 0.7071 To learn about a function xyz, type: >> help xyz Recitation 1. 6
Variables MATLAB does not require any variable type declarations or dimension statements to define variables When defining a variable, it must appear on the left side of the equality sign Multiplication must be explicit, that is, include the multiplication symbol * Recitation 1. 7
Problem 1 Use Euler's identity to determine the rectangular form of Verify your result using the MATLAB command window MATLAB recognizes i and j as the square root of -1 Use 1i to improve calculation speed Recitation 1. 8
Vectors Row vector: >> w = [1, 2, 3, 4] Column vector: >> x = [1; 2; 3; 4] Row Vector of 5 ones: >> y = ones(1,5) Column vector of 5 ones: >> x = ones(5,1) Row vector of 3 zeros: >> a = zeros(1,3) A vector [1, 1.5, 2]: >> b = [1 : 0.5 : 2] A row vector of 100 points evenly spaced between 0 and 10: >> c = linspace(0,10); The semicolon suppresses the echo! Recitation 1. 9
Scripts MATLAB statements may be executed in a script as control flow program Generate a script by choosing New Script (Ctrl + N) Recitation 1. 10
Problem 2 Write a script that plots cos(t) and sin(t) versus t using 100 points uniformly distributed over the interval 0 to 4 Plot the cosine signal using a solid black curve, and the sine signal using a dotted blue curve Use the legend command to distinguish the curves in the plot Use the xlabel, ylabel, and title commands to label the plot Recitation 1. 11
Problem 3(A) Consider the capacitor shown below 1. What is i(t) in terms of v(t)? 2. What is the energy stored in the capacitor? 3. What is v(t) in terms of i(t)? 4. Can v(t) change instantaneously? Why? 5. Can i(t) change instantaneously? Recitation 1. 12
Problem 3(A) Solution Recitation 1. 13
Problem 3(A) Solution Recitation 1. 14
Problem 3(B) Consider the inductor shown below 1. What is v(t) in terms of i(t)? 2. What is the energy stored in the inductor? 3. What is i(t) in terms of v(t)? 4. Can i(t) change instantaneously? Why? 5. Can v(t) change instantaneously? Recitation 1. 15
Problem 3(B) Solution Recitation 1. 16
Problem 3(B) Solution Recitation 1. 17
Problem 4 Consider the RC circuit below, where the switched has been opened a long time before it is closed at time t = 0. 1. Determine v(0 ) and i(0 ) 2. Determine v(0 + ) and i(0 + ) 3. Determine v( ) and i( ) 4. Obtain an ODE that describes the response of v(t) for t 0 Recitation 1. 18
Problem 4 Solution Recitation 1. 19
Problem 4 Solution Recitation 1. 20
Problem 4 Solution Recitation 1. 21
Problem 4 Solution Recitation 1. 22
Problem 4 Solution Recitation 1. 23
Problem 5 Consider the RLC circuit below, where the switched has been closed a long time before it is opened at time t = 0. 1. Obtain an ODE that describes the response of i(t) for t 0. 2. Determine the initial conditions, i(t) and di/dt at time t = 0 +. 3. Determine i(t) after the switch has been opened a long time. Recitation 1. 24
Problem 5 Solution Recitation 1. 25
Problem 5 Solution Recitation 1. 26
Problem 5 Solution Recitation 1. 27
Problem 5 Solution Recitation 1. 28