diff --git a/src/timeresp.jl b/src/timeresp.jl index 89eab2811..66d5da69f 100644 --- a/src/timeresp.jl +++ b/src/timeresp.jl @@ -85,6 +85,10 @@ The result structure contains the fields `y, t, x, u` and can be destructured au ```julia y, t, x, u = result ``` +`result::SimResult` can also be plotted directly: +```julia +plot(result, plotu=true, plotx=false) +``` `y`, `x`, `u` have time in the second 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 (with `method=:zoh` by default) before simulation. For a lower level inteface, see `?Simulator` and `?solve` diff --git a/src/types/result_types.jl b/src/types/result_types.jl index df84af793..b4e927e8e 100644 --- a/src/types/result_types.jl +++ b/src/types/result_types.jl @@ -3,6 +3,28 @@ abstract type AbstractResult end # Common for all result types, e.g., SimResult ## SimResult: the output of lsim etc. ========================================== abstract type AbstractSimResult <: AbstractResult end # Result of a time-domain simulation + +""" + SimResult{Ty, Tt, Tx, Tu, Ts} <: AbstractSimResult + +Result structure containing the results of time-domain simulations using `lsim, step, impulse`. +The structure can be plotted using +```julia +result = lsim(...) +plot(result, plotu=true, plotx=false) +``` +and destructured like +```julia +y, t, x, u = result +``` + +# Fields: +- `y::Ty` +- `t::Tt` +- `x::Tx` +- `u::Tu` +- `sys::Ts` +""" struct SimResult{Ty, Tt, Tx, Tu, Ts} <: AbstractSimResult # Result of lsim y::Ty t::Tt