Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate changes from #344 #881

Merged
merged 3 commits into from
Oct 11, 2023
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workbench.colorTheme": "Julia (Monokai Vibrant)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this really supposed to be added?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, no certainly not :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, no. VSCode keeps adding this file in every folder I open with VSCode, which has made its way into more than one git commit. I will make a PR to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the folder in #882

}
28 changes: 26 additions & 2 deletions docs/src/man/creating_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
```

### tf - Rational Representation
The syntax for creating a transfer function is [`tf`](@ref)
The basic syntax for creating a transfer function is [`tf`](@ref)
```julia
tf(num, den) # Continuous-time system
tf(num, den, Ts) # Discrete-time system
Expand All @@ -34,6 +34,30 @@ Continuous-time transfer function model
```

The transfer functions created using this method will be of type `TransferFunction{SisoRational}`.
For more general expressions, it is often more convenient to define `s = tf("s")`:
#### Example:
```julia
julia> s = tf("s")

TransferFunction{Continuous,ControlSystems.SisoRational{Int64}}
s
-
1

Continuous-time transfer function model
```

This allows us to use `s` to define transfer-functions:
```julia
julia> (s-1)*(s^2 + s + 1)/(s^2 + 3s + 2)/(s+1)

TransferFunction{Continuous,ControlSystems.SisoRational{Int64}}
s^3 - 1
---------------------
s^3 + 4*s^2 + 5*s + 2

Continuous-time transfer function model
```

### zpk - Pole-Zero-Gain Representation
Sometimes it's better to represent the transfer function by its poles, zeros and gain, this can be done using the function [`zpk`](@ref)
Expand Down Expand Up @@ -84,7 +108,7 @@ To associate **names** with states, inputs and outputs, see [`named_ss`](https:/


## Converting between types
It is sometime useful to convert one representation to another, this is possible using the constructors `tf, zpk, ss`, for example
It is sometime useful to convert one representation to another. This is possible using the constructors `tf, zpk, ss`, for example
```jldoctest
tf(zpk([-1], [1], 2, 0.1))

Expand Down
27 changes: 20 additions & 7 deletions lib/ControlSystemsBase/src/timeresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ LsimWorkspace(sys::AbstractStateSpace, u::AbstractMatrix) = LsimWorkspace(sys, s
y, t, x = step(sys[, tfinal])
y, t, x = step(sys[, t])

Calculate the step response of system `sys`. If the final time `tfinal` or time
vector `t` is not provided, one is calculated based on the system pole
locations. The return value is a structure of type `SimResult` that can be plotted or destructured as `y, t, x = result`.
Calculate the response of the system `sys` to a unit step at time `t = 0`.
If the final time `tfinal` or time vector `t` is not provided,
one is calculated based on the system pole locations.

The return value is a structure of type `SimResult`.
A `SimResul` can be plotted by `plot(result)`,
or destructured as `y, t, x = result`.

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

Expand Down Expand Up @@ -73,11 +77,20 @@ Base.step(sys::TransferFunction, t::AbstractVector; kwargs...) = step(ss(sys), t
y, t, x = impulse(sys[, tfinal])
y, t, x = impulse(sys[, t])

Calculate the impulse response of system `sys`. If the final time `tfinal` or time
vector `t` is not provided, one is calculated based on the system pole
locations. The return value is a structure of type `SimResult` that can be plotted or destructured as `y, t, x = result`.
Calculate the response of the system `sys` to an impulse at time `t = 0`.
For continous-time systems, the impulse is a unit Dirac impulse.
For discrete-time systems, the impulse lasts one sample and has magnitude `1/Ts`.
If the final time `tfinal` or time vector `t` is not provided,
one is calculated based on the system pole locations.

The return value is a structure of type `SimResult`.
A `SimResul` can be plotted by `plot(result)`,
or destructured as `y, t, x = result`.

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

See also [`lsim`](@ref).
"""
function impulse(sys::AbstractStateSpace, t::AbstractVector; kwargs...)
T = promote_type(eltype(sys.A), Float64)
ny, nu = size(sys)
Expand Down
Loading