We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f7cf8c0 + 44242f0 commit 7e3e22eCopy full SHA for 7e3e22e
2 files changed
src/matrix_comps.jl
@@ -107,11 +107,12 @@ Compute the observability matrix for the system described by `(A, C)` or `sys`.
107
Note that checking for observability by computing the rank from `obsv` is
108
not the most numerically accurate way, a better method is checking if
109
`gram(sys, :o)` is positive definite."""
110
-function obsv(A::AbstractMatrix{T}, C::AbstractMatrix) where T
+function obsv(A::AbstractMatrix, C::AbstractMatrix)
111
+ T = promote_type(eltype(A), eltype(C))
112
n = size(A, 1)
113
ny = size(C, 1)
114
if n != size(C, 2)
- error("C must have the same number of columns as A")
115
+ throw(ArgumentError("C must have the same number of columns as A"))
116
end
117
res = fill(zero(T), n*ny, n)
118
res[1:ny, :] = C
@@ -130,11 +131,12 @@ Compute the controllability matrix for the system described by `(A, B)` or
130
131
Note that checking for controllability by computing the rank from
132
`ctrb` is not the most numerically accurate way, a better method is
133
checking if `gram(sys, :c)` is positive definite."""
-function ctrb(A::AbstractMatrix{T}, B::AbstractMatrix{T}) where {T <: Number}
134
+function ctrb(A::AbstractMatrix, B::AbstractMatrix)
135
+ T = promote_type(eltype(A), eltype(B))
136
137
nu = size(B, 2)
138
if n != size(B, 1)
- error("B must have the same number of rows as A")
139
+ throw(ArgumentError("B must have the same number of rows as A"))
140
141
res = fill(zero(T), n, n*nu)
142
res[:, 1:nu] = B
src/synthesis.jl
@@ -25,11 +25,11 @@ Q = I
25
R = I
26
L = lqr(sys,Q,R)
27
28
-u(t,x) = -L*x # Form control law,
+u(x,t) = -L*x # Form control law,
29
t=0:0.1:5
30
x0 = [1,0]
31
-y, t, x, uout = lsim(sys,u,t,x0)
32
-plot(t,x, lab=["Position", "Velocity"]', xlabel="Time [s]")
+y, t, x, uout = lsim(sys,u,t,x0=x0)
+plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")
33
```
34
"""
35
function lqr(A, B, Q, R)
@@ -87,11 +87,11 @@ Q = I
87
88
L = dlqr(A,B,Q,R) # lqr(sys,Q,R) can also be used
89
90
91
t=0:h:5
92
93
94
95
96
97
function dlqr(A, B, Q, R)
0 commit comments