Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/timeresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
22 changes: 22 additions & 0 deletions src/types/result_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down