You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/matrix_comps.jl
+11-8Lines changed: 11 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -168,8 +168,9 @@ function covar(sys::AbstractStateSpace, W)
168
168
func =iscontinuous(sys) ? lyap : dlyap
169
169
Q =try
170
170
func(A, B*W*B')
171
-
catch
172
-
error("No solution to the Lyapunov equation was found in covar")
171
+
catch e
172
+
@error("No solution to the Lyapunov equation was found in covar.")
173
+
rethrow(e)
173
174
end
174
175
P = C*Q*C'
175
176
if!isdiscrete(sys)
@@ -493,9 +494,9 @@ end
493
494
494
495
495
496
"""
496
-
`sysr, G = balreal(sys::StateSpace)`
497
+
`sysr, G, T = balreal(sys::StateSpace)`
497
498
498
-
Calculates a balanced realization of the system sys, such that the observability and reachability gramians of the balanced system are equal and diagonal `G`
499
+
Calculates a balanced realization of the system sys, such that the observability and reachability gramians of the balanced system are equal and diagonal `G`. `T` is the similarity transform between the old state `x` and the new state `z` such that `Tz = x`.
499
500
500
501
See also `gram`, `baltrunc`
501
502
@@ -531,23 +532,25 @@ function balreal(sys::ST) where ST <: AbstractStateSpace
sysr =ST(T*sys.A/T, T*sys.B, sys.C/T, sys.D, sys.timeevol), diagm(Σ), T
535
536
end
536
537
537
538
538
539
"""
539
-
sysr, G = baltrunc(sys::StateSpace; atol = √ϵ, rtol=1e-3, unitgain=true, n = nothing)
540
+
sysr, G, T = baltrunc(sys::StateSpace; atol = √ϵ, rtol=1e-3, unitgain=true, n = nothing)
540
541
541
542
Reduces the state dimension by calculating a balanced realization of the system sys, such that the observability and reachability gramians of the balanced system are equal and diagonal `G`, and truncating it to order `n`. If `n` is not provided, it's chosen such that all states corresponding to singular values less than `atol` and less that `rtol σmax` are removed.
542
543
544
+
`T` is the similarity transform between the old state `x` and the newstate `z` such that `Tz = x`.
545
+
543
546
If `unitgain=true`, the matrix `D` is chosen such that unit static gain is achieved.
544
547
545
548
See also `gram`, `balreal`
546
549
547
550
Glad, Ljung, Reglerteori: Flervariabla och Olinjära metoder
548
551
"""
549
552
functionbaltrunc(sys::ST; atol =sqrt(eps()), rtol =1e-3, unitgain =true, n =nothing) where ST <:AbstractStateSpace
550
-
sysbal, S =balreal(sys)
553
+
sysbal, S, T=balreal(sys)
551
554
S =diag(S)
552
555
if n ===nothing
553
556
S = S[S .>= atol]
@@ -564,7 +567,7 @@ function baltrunc(sys::ST; atol = sqrt(eps()), rtol = 1e-3, unitgain = true, n =
0 commit comments