Time and Frequency response

# Time and Frequency response

Any `TransferFunction` can be evaluated at a point using `F(s)`, `F(omega, true)`, `F(z, false)`

• `F(s)` evaluates the continuous-time transfer function `F` at `s`.
• `F(omega,true)` evaluates the discrete-time transfer function `F` at `exp(i*Ts*omega)`
• `F(z,false)` evaluates the discrete-time transfer function `F` at `z`

`mag, phase, w = bode(sys[, w])`

Compute the magnitude and phase parts of the frequency response of system `sys` at frequencies `w`

`mag` and `phase` has size `(length(w), ny, nu)`

source

`evalfr(sys, x)` Evaluate the transfer function of the LTI system sys at the complex number s=x (continuous-time) or z=x (discrete-time).

For many values of `x`, use `freqresp` instead.

source

sys_fr = freqresp(sys, w)

Evaluate the frequency response of a linear system

`w -> C*((iw*im -A)^-1)*B + D`

of system `sys` over the frequency vector `w`.

source

`y, t, x = impulse(sys[, Tf])` or `y, t, x = impulse(sys[, t])`

Calculate the impulse response of system `sys`. If the final time `Tf` or time vector `t` is not provided, one is calculated based on the system pole locations.

`y` has size `(length(t), ny, nu)`, `x` has size `(length(t), nx, nu)`

source

`y, t, x = lsim(sys, u, t; x0, method])`

`y, t, x, uout = lsim(sys, u::Function, t; x0, method)`

Calculate the time response of system `sys` to input `u`. If `x0` is ommitted, a zero vector is used.

`y`, `x`, `uout` has time in the first dimension. Initial state `x0` defaults to zero.

Continuous time systems are simulated using an ODE solver if `u` is a function. If `u` is an array, the system is discretized before simulation. For a lower level inteface, see `?Simulator` and `?solve`

`u` can be a function or a matrix/vector of precalculated control signals. If `u` is a function, then `u(x,i)` (`u(x,t)`) is called to calculate the control signal every iteration (time instance used by solver). This can be used to provide a control law such as state feedback `u(x,t) = -L*x` calculated by `lqr`. To simulate a unit step, use `(x,i)-> 1`, for a ramp, use `(x,i)-> i*h`, for a step at `t=5`, use (x,i)-> (i*h >= 5) etc.

Usage example:

``````using LinearAlgebra # For identity matrix I
using Plots

A = [0 1; 0 0]
B = [0;1]
C = [1 0]
sys = ss(A,B,C,0)
Q = I
R = I
L = lqr(sys,Q,R)

u(x,t) = -L*x # Form control law,
t=0:0.1:5
x0 = [1,0]
y, t, x, uout = lsim(sys,u,t,x0=x0)
plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")``````
source

`re, im, w = nyquist(sys[, w])`

Compute the real and imaginary parts of the frequency response of system `sys` at frequencies `w`

`re` and `im` has size `(length(w), ny, nu)`

source

`y, t, x = step(sys[, Tf])` or `y, t, x = step(sys[, t])`

Calculate the step response of system `sys`. If the final time `Tf` or time vector `t` is not provided, one is calculated based on the system pole locations.

`y` has size `(length(t), ny, nu)`, `x` has size `(length(t), nx, nu)`

source