|
363 | 363 | """ |
364 | 364 | measure(s::NamedStateSpace, names) |
365 | 365 |
|
366 | | -Return a system with specified states as measurement outputs. |
| 366 | +Return a system with specified state variables as measurement outputs. |
| 367 | +
|
| 368 | +See also [`add_output`](@ref). |
367 | 369 | """ |
368 | 370 | function measure(s::NamedStateSpace, names) |
369 | 371 | inds = names2indices(names, s.x) |
@@ -840,6 +842,27 @@ function CS.append(systems::NamedStateSpace...; kwargs...) |
840 | 842 | end |
841 | 843 |
|
842 | 844 |
|
| 845 | +""" |
| 846 | + add_output(sys::NamedStateSpace, C2::AbstractArray, D2 = 0; y) |
| 847 | +
|
| 848 | +Add outputs to `sys` corresponding to the output matrix `C2` and the feedthrough matrix `D2` to the system `sys`. |
| 849 | +
|
| 850 | +# Arguments: |
| 851 | +- `y`: The names used for the new outputs. If not provided, the names will be generated automatically. |
| 852 | +
|
| 853 | +See also [`measure`](@ref) for a simpler way to output state variables. |
| 854 | +""" |
| 855 | +function CS.add_output(sys::NamedStateSpace, C2::AbstractArray, D2=0; y = [Symbol("y_$i") for i in (1:size(C2, 1)) .+ sys.ny]) |
| 856 | + T = promote_type(CS.numeric_type(sys), eltype(C2), eltype(D2)) |
| 857 | + A,B,C,D = ssdata(sys) |
| 858 | + D3 = D2 == 0 ? zeros(T, size(C2, 1), sys.nu) : D2 |
| 859 | + x = sys.x |
| 860 | + u = sys.u |
| 861 | + y = [sys.y; y] |
| 862 | + named_ss(ss(A, B, [C; C2], [D; D3]), sys.timeevol; x, u, y) |
| 863 | +end |
| 864 | + |
| 865 | + |
843 | 866 | function CS.minreal(sys::NamedStateSpace, args...; kwargs...) |
844 | 867 | msys = minreal(sys.sys, args...; kwargs...) |
845 | 868 | named_ss(msys; sys.u, sys.y, sys.name) |
|
0 commit comments