Skip to content

Commit cc60d9d

Browse files
committed
expand docs for named ss
1 parent 8687290 commit cc60d9d

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

docs/src/index.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,23 @@ pkg> add RobustAndOptimalControl
5454
```
5555

5656
## Named systems
57-
See [complicated-feedback example](https://github.com/JuliaControl/RobustAndOptimalControl.jl/blob/master/examples/complicated_feedback.jl)
58-
- [`named_ss`](@ref)
5957

60-
Named systems can be indexed with their names, e.g.,
61-
```julia
62-
G[:y2, :u4]
58+
Named systems can be created with [`named_ss`](@ref) and indexed with their names, e.g.,
59+
```@repl
60+
G = ssrand(2,2,2);
61+
s1 = named_ss(G, x = :x, u = [:u_temp, :u_current]) # Create a named system
62+
s1[:y1, :u_temp] # Access inputs and outputs using their names
6363
```
6464
but also using incomplete names, e.g., if `G` contains outputs `:y1, :y2, :y3, :z1, :z2`, the following retrieves the three outputs that has the prefix `:y`
65-
```julia
66-
G[:y, :] # Prefix matching is used if no exact match is found.
65+
```@repl
66+
s1[:y, :] # Prefix matching is used if no exact match is found.
6767
```
6868

69+
See [complicated-feedback example](https://github.com/JuliaControl/RobustAndOptimalControl.jl/blob/master/examples/complicated_feedback.jl) as well as the example under [Connecting systems together](@ref) below for additional examples.
70+
6971
## Connecting systems together
70-
See [complicated-feedback example](https://github.com/JuliaControl/RobustAndOptimalControl.jl/blob/master/examples/complicated_feedback.jl)
71-
- [`connect`](@ref)
72+
Advanced interconnected systems can be created using the function [`connect`](@ref).
73+
See [complicated-feedback example](https://github.com/JuliaControl/RobustAndOptimalControl.jl/blob/master/examples/complicated_feedback.jl) as well as the following example:
7274

7375
### Example
7476
The following complicated feedback interconnection

src/named_systems2.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ Base.:^(s::Symbol, n::Int) = expand_symbol(s, n)
116116
"""
117117
named_ss(sys::AbstractStateSpace{T}; x, u, y)
118118
119-
Create a `NamedStateSpace` system. This kind of system uses names rather than integer indices to refer to states, inputs and outputs
119+
Create a `NamedStateSpace` system. This kind of system uses names rather than integer indices to refer to states, inputs and outputs.
120+
- If a single name is provided but a vector of names is expected, this name will be used as prefix followed by a numerical index.
121+
- If no name is provided, default names (`x,y,u`) will be used.
120122
121123
# Arguments:
122124
- `sys`: A system to add names to.
123125
- `x`: A list of symbols with names of the states.
124126
- `u`: A list of symbols with names of the inputs.
125127
- `y`: A list of symbols with names of the outputs.
126128
127-
Default names of signals if none are provided are `x,u,y`.
128129
129130
# Example
130131
```julia
@@ -133,7 +134,7 @@ G2 = ss(1,1,1,0)
133134
s1 = named_ss(G1, x = :x, u = :u1, y=:y1)
134135
s2 = named_ss(G2, x = :z, u = :u2, y=:y2)
135136
136-
s1[:y1, :u1] # Index using symbols
137+
s1[:y1, :u1] # Index using symbols. Uses prefix matching if no exact match is found.
137138
138139
fb = feedback(s1, s2, r = :r) #
139140
```
@@ -163,7 +164,7 @@ end
163164
"""
164165
named_ss(sys::AbstractStateSpace, name; x, y, u)
165166
166-
If a single name is provided, the outputs, inputs and states will be automatically named
167+
If a single name of the system is provided, the outputs, inputs and states will be automatically named
167168
`y,u,x` with `name` as prefix.
168169
"""
169170
function named_ss(sys::AbstractStateSpace, name;

0 commit comments

Comments
 (0)