CDS 101/110: Lecture 3.1 Linear Systems

Goals for Today: • Revist and motivate linear time-invariant system models: • Summarize properties, examples, and tools − Convolution equation describing solution in response to an input − Step response, response • Characterize performance of linear systems

Reading: • Åström and Murray, FBS-2e, Ch 6.1-6.3

1 Why are Linear Systems Important?

u(t)

Many important examples q2 q1 • Mechanical Systems m1 m2

k1 k2 k3

c m 

x

f M

2 Why are Linear Systems Important?

3 Why are Linear Systems Important?

Many important examples • Electronic circuits

− Especially true after feedback − Frequency response is key performance specification 4 Why are Linear Systems Important?

Many important examples Many important tools • Frequency and step response, – Traditional tools of – Developed in 1930’s at Bell Labs CDS 110 • Classical control design toolbox – Nyquist plots, gain/ margin – Loop shaping

• Optimal control and estimators CDS – u(t) Linear quadratic regulators 112

q2 – Kalman estimators q1 m1 m2 • Robust control design CDS k1 k2 k3 – H1 control design 212/ c – µ analysis for structured 213 uncertainty 5 Solutions of Linear Time Invariant Systems: “Modes”

Linear Time Invariant (LTI) System: • If Linear System, input u(t) leads to output y(t) • If u(t+T) leads to output y(t+T), the system is time invariant

• Matrix LTI system, with no input

• Let and be eigenvalue/eigenvector of . Then: ^2 𝑖𝑖 =𝑖𝑖 + + + = + + + 𝜆𝜆 𝑣𝑣 1! 22! 𝐴𝐴 1! 2! 𝐴𝐴𝐴𝐴 𝑡𝑡 𝑡𝑡 2 𝑡𝑡 𝑡𝑡 2 𝑒𝑒 𝑣𝑣𝑖𝑖 = 𝐼𝐼 𝐴𝐴 𝐴𝐴 ⋯ 𝑣𝑣𝑖𝑖 𝑣𝑣𝑖𝑖 𝜆𝜆𝑖𝑖𝑣𝑣𝑖𝑖 𝜆𝜆𝑖𝑖 𝑣𝑣𝑖𝑖 ⋯ • If n distinct eigenvalues,𝜆𝜆𝑖𝑖𝑡𝑡 then 0 = + + + , and 𝑒𝑒 𝑣𝑣𝑖𝑖 0 = + 1 1 +2 2 + 𝑛𝑛 𝑛𝑛 Sum of 𝑥𝑥 𝛼𝛼 𝑣𝑣 𝛼𝛼 𝑣𝑣 ⋯ 𝛼𝛼 𝑣𝑣 “modes” 𝐴𝐴𝐴𝐴 𝜆𝜆1𝑡𝑡 𝜆𝜆2𝑡𝑡 𝜆𝜆𝑛𝑛𝑡𝑡 1 1 2 2 𝑛𝑛 𝑛𝑛 𝑒𝑒 𝑥𝑥 𝛼𝛼 𝑒𝑒 𝑣𝑣 𝛼𝛼 𝑒𝑒 𝑣𝑣 ⋯ 𝛼𝛼 𝑒𝑒 𝑣𝑣 6 The Convolution Integral: Step 1

Let denote the response of a LTI system to a unit step input at t=0. – Assuming the system starts at Equilibrium 𝐻𝐻 𝑡𝑡 The response to the steps are: – First step input at time t=0: – Second step input at time : ( ) 𝐻𝐻 𝑡𝑡 − 𝑡𝑡0 𝑢𝑢 𝑡𝑡0 – Third step input at time : ( ) 𝑡𝑡1 𝐻𝐻 𝑡𝑡 − 𝑡𝑡1 𝑢𝑢 𝑡𝑡1 − 𝑢𝑢 𝑡𝑡0 By linearity, we can add the response𝑡𝑡2 𝐻𝐻 𝑡𝑡 − 𝑡𝑡2 𝑢𝑢 𝑡𝑡2 − 𝑢𝑢 𝑡𝑡1 = + + … = + ( ) 𝑦𝑦 𝑡𝑡 𝐻𝐻 𝑡𝑡 − 𝑡𝑡0 𝑢𝑢 𝑡𝑡0 𝐻𝐻 𝑡𝑡 − 𝑡𝑡1 𝑢𝑢 𝑡𝑡1 − 𝑢𝑢 𝑡𝑡0 + … 0 1 0 1 2 1 = 𝑡𝑡0𝐻𝐻<𝑡𝑡 𝑡𝑡 − 𝑡𝑡 − 𝐻𝐻 𝑡𝑡 − 𝑡𝑡 𝑢𝑢 𝑡𝑡 ( 𝐻𝐻)( 𝑡𝑡 − 𝑡𝑡 −)𝐻𝐻 𝑡𝑡 − 𝑡𝑡 𝑢𝑢 𝑡𝑡 𝑛𝑛 𝑛𝑛+1 𝐻𝐻 𝑡𝑡 − 𝑡𝑡 − 𝐻𝐻 𝑡𝑡 − 𝑡𝑡 𝑛𝑛 𝑛𝑛+1 𝑛𝑛 � 𝑛𝑛+1 𝑛𝑛 0 𝑢𝑢 𝑡𝑡 𝑡𝑡 − 𝑡𝑡 Taking the𝑛𝑛 =limit0 as 𝑡𝑡 − 𝑡𝑡 𝑛𝑛+1 𝑛𝑛 = 𝑡𝑡 − 𝑡𝑡 → 𝑡𝑡 ′ 7 𝑦𝑦 𝑡𝑡 �0 𝐻𝐻 𝑡𝑡 − 𝜏𝜏 𝑢𝑢 𝜏𝜏 𝑑𝑑𝑑𝑑 Impulse Response

homogeneous • What is the “impulse response” due to u(t)=δ(t)? take limit as dt 0 but keep unit area

u → 1/dt 0 < 0 t = = 1/ 0 < = lim ( ) dt 0 𝑡𝑡 𝑢𝑢 𝑡𝑡 𝑝𝑝𝜀𝜀 𝑡𝑡 � 𝜀𝜀 ≤ 𝑡𝑡 𝜀𝜀 𝛿𝛿 𝑡𝑡 𝜀𝜀→0 𝑝𝑝𝜀𝜀 𝑡𝑡 • Apply this unit impulse to the system (with x(0)=0):𝑡𝑡 ≥ 𝜀𝜀

= 𝐴𝐴𝐴𝐴 𝑦𝑦 𝑡𝑡 𝐶𝐶𝑒𝑒 𝐵𝐵

8 Response to inputs: Convolution

homogeneous At • Impulse response, h(t) = Ce B – Response to input “impulse” – Equivalent to “Green’s function”

• Linearity ⇒ compose response to arbitrary u(t) using convolution – Decompose input into “sum” of shifted impulse functions – Compute impulse response for each – “Sum” impulse response to find y(t) – Take limit as dt→ 0 • Complete solution: use integral instead of “sum” • linear with respect to initial condition and input • 2X input ⇒ 2X output when x(0) = 0 Convolution Theorem 9 MATLAB Tools for Linear Systems

Initial Condition Results A = [-1 1; 0 -1]; B = [0; 1]; 1

C = [1 0]; D = [0]; 0.8 x0 = [1; 0.5]; 0.6

To: Y(1) 0.4 sys = ss(A,B,C,D); 0.2 0 initial(sys, x0); 0 1 2 3 4 5 6 7 impulse(sys); Linear Simulation Results 1 t = 0:0.1:10; 0.5 u = 0.2*sin(5*t) + cos(2*t); To: Y(1)

Amplitude 0 lsim(sys, u, t, x0);

-0.5 0 1 2 3 4 5 6 7 8 9 10 • Other MATLAB commands Time (sec.) – gensig, square, sawtooth – produce signals of diff. types ltiview – linear time invariant – step, impulse, initial, lsim – time domain analysis system plots – bode, freqresp, evalfr – analysis

10 MATLAB Tools for Phase Space

System Equations MATLAB CODE = 2 [x1, x2]=meshgrid(-0.5:0.05:0.5, -0.5:0.05:0.5); = 2 x1dot=-x1 - 2*x2*x1^2 + x2; 𝑥𝑥̇1 −𝑥𝑥1 − 𝑥𝑥2𝑥𝑥1 𝑥𝑥2 x2dot=-x1-x2; 𝑥𝑥̇2 −𝑥𝑥1 − 𝑥𝑥2 quiver(x1,x2,x1dot,x2dot); x

0.6

0.4

0.2

0

-0.2

-0.4

-0.6 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 11 MATLAB Tools for Phase Space

function my_phases(IC) hold on [~,X]=ode45(@EOM,[0,50],IC);

u=X(:,1); 0.6 w=X(:,2);

plot(u,w,'r'); 0.4 xlabel('u') ylabel('w') 0.2 grid

0 end w function dX=EOM(t,X) -0.2 dX=zeros(2,1); x1=X(1); -0.4 x2=X(2);

-0.6 x1dot=-x1 - 2*x2*x1^2 + x2; -0.6 -0.4 -0.2 0 0.2 0.4 0.6 x2dot=-x1-x2; u dX=[x1dot;x2dot]; end

12 Input/Output Performance

• How does system respond to changes in input values? – : – Steady state response: • Characterize response in terms of – Impulse response Transient Steady State – Step response – Frequency response

Mass spring system (L1.2)

Response to I.C.s, Response to inputs, Transient response Steady State (if constant inputs)

13 Step Response

• Output characteristics in response to a “step” input – : time required to move from 5% to 95% of final value – : ratio between amplitude of first peak and steady state value – Settling time: time required to remain w/in p% (usually 2%) of final value – Steady state value: final value at t = 1

1.5 Overshoot

1

Steady state value Amplitude 0.5 Rise time Settling time

0 0 5 10 15 20 25 Time (sec.) 14 Frequency Response • Measure steady state response of system to sinusoidal input – Example: audio – would like consistent (“flat”) amplification between 20 Hz & 20,000 Hz – Individual sinusoids are good test signals for measuring performance in many systems

• Approach: plot input and output, measure relative amplitude and phase – Use MATLAB or SIMULINK to generate 1.5 u response of system to sinusoidal output 1 Au y A – Gain = Ay/Au 0.5 y – Phase = 2π ∙ ΔT/T 0 T Amplitude -0.5 Δ • May not work for nonlinear systems -1 T -1.5 – System nonlinearities can cause 0 5 10 15 20 harmonics to appear in the output Time (sec.) – Amplitude and phase may not be well-defined – For linear systems, frequency response is always well defined

15 Computing Frequency Responses • Technique #1: plot input and output, measure relative amplitude and phase – Generate response of system to 1.5 u sinusoidal output 1 Au y

0.5 Ay – Gain = Ay/Au – Phase = 2π ∙ ΔT/T 0 – For linear system, gain and phase -0.5 ΔT T don’t depend on the input amplitude -1 -1.5 0 5 10 15 20 • Technique #2 (linear systems): use bode (or freqresp) command

– Assumes linear dynamics in state 20 10 bode(ss(A,B,C,D)) space form: 0 -10 -20 -30 -40

Magnitude (dB) -50 -60 – Gain plotted on log-log scale 0 -90 • dB = 20 log10 (gain) – Phase plotted on linear-log scale -180 -270 Phase (deg) -360 0.1 1 10 Frequency (rad/sec) 16 Calculating Frequency Response from convolution equation

• Convolution equation describes response to any input; use this to look at response to sinusoidal input: u(t)

Transient (decays if stable) Ratio of response/input

“Frequency response” 17 Second Order Systems • Many important examples: • Insight to response for higher orders (eigenvalues of A are either real or complex) – Exception is non-diagonalizable A (non-trivial Jordan form)

2 1.8 1.6 T=2π/ω0 1.4 1.2

y 1

0.8 0.6 ζ 0.4 0.2

0 0 5 10 15 20 25

time (sec)

– Analytical formulas exist for overshoot, rise time, settling time, etc – Will study more next week 18 Frequency Spring Mass System response: C(jωI-A)-1B+D Eigenvalues of A: u(t) • For zero damping, jω1 and jω2 q 2 • ω ω q1 1 and 2 correspond frequency

m1 m2 response peaks • The eigenvectors for these eigenvalues k 1 k2 k3 give the mode shape: – In-phase motion for lower freq. c – Out-of phase motion for higher freq.

Frequency Response

10

1

0.1

0.01 Gain (log scale) 0.001 0

-90

-180

-270 Phase [deg] -360 0.1 Frequency1 [rad/sec] 19 10 Summary: Linear Systems

u y

1 1

0 0

-1 -1 + 0 5 10 + 0 5 10 1 0.5

0 0

-1 -0.5 0 5 10 0 5 10 • Properties of linear systems 2 2 – Linearity with respect to initial condition 0 0 and inputs -2 -2 0 5 10 0 5 10 – Stability characterized by eigenvalues – Many applications and tools available – Provide local description for nonlinear systems

20 Example: Inverted Pendulum on a Cart m 

 State:  Input: u = F x  Output: y = x  Linearize according to previous f formula around  = 0 M

22 Second Order Systems • Many important examples: • Response of 1st and 2nd order systems -> insight to response for higher orders (eigenvalues of A are either real or complex) – Exception is non-diagonalizable A (non-trivial Jordan form)

2 1.8 1.6 T=2π/ω0 1.4 1.2 1 y 1 0.8 0<ζ<1 0.5 0.6 ζ 0.4 ) ζ

λ >1 0.2 0

0 Imag( 0 5 10 15 20 25 -0.5 time (sec) 0<ζ<1 – Analytical formulas exist for overshoot, rise time, settling time, etc -1 -2 -1.5 -1 -0.5 0 – Will study more next week Real(λ) 23 Second Order Systems

Important class of systems in many applications areas

2 1.8 1.6 T=2/ 0 1.4 1.2 y 1 0.8 0.6  0.4 0.2 0 0 5 10 15 20 25 time (sec)  Analytical formulas exist for overshoot, rise time, settling time, etc  Will study second order systems characteristics in more detail next week

24