Skip to content

Commit 7e3e22e

Browse files
committed
Merge branch 'project.toml' of github.com:JuliaControl/ControlSystems.jl into project.toml
2 parents f7cf8c0 + 44242f0 commit 7e3e22e

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/matrix_comps.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ Compute the observability matrix for the system described by `(A, C)` or `sys`.
107107
Note that checking for observability by computing the rank from `obsv` is
108108
not the most numerically accurate way, a better method is checking if
109109
`gram(sys, :o)` is positive definite."""
110-
function obsv(A::AbstractMatrix{T}, C::AbstractMatrix) where T
110+
function obsv(A::AbstractMatrix, C::AbstractMatrix)
111+
T = promote_type(eltype(A), eltype(C))
111112
n = size(A, 1)
112113
ny = size(C, 1)
113114
if n != size(C, 2)
114-
error("C must have the same number of columns as A")
115+
throw(ArgumentError("C must have the same number of columns as A"))
115116
end
116117
res = fill(zero(T), n*ny, n)
117118
res[1:ny, :] = C
@@ -130,11 +131,12 @@ Compute the controllability matrix for the system described by `(A, B)` or
130131
Note that checking for controllability by computing the rank from
131132
`ctrb` is not the most numerically accurate way, a better method is
132133
checking if `gram(sys, :c)` is positive definite."""
133-
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))
134136
n = size(A, 1)
135137
nu = size(B, 2)
136138
if n != size(B, 1)
137-
error("B must have the same number of rows as A")
139+
throw(ArgumentError("B must have the same number of rows as A"))
138140
end
139141
res = fill(zero(T), n, n*nu)
140142
res[:, 1:nu] = B

src/synthesis.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ Q = I
2525
R = I
2626
L = lqr(sys,Q,R)
2727
28-
u(t,x) = -L*x # Form control law,
28+
u(x,t) = -L*x # Form control law,
2929
t=0:0.1:5
3030
x0 = [1,0]
31-
y, t, x, uout = lsim(sys,u,t,x0)
32-
plot(t,x, lab=["Position", "Velocity"]', xlabel="Time [s]")
31+
y, t, x, uout = lsim(sys,u,t,x0=x0)
32+
plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")
3333
```
3434
"""
3535
function lqr(A, B, Q, R)
@@ -87,11 +87,11 @@ Q = I
8787
R = I
8888
L = dlqr(A,B,Q,R) # lqr(sys,Q,R) can also be used
8989
90-
u(t,x) = -L*x # Form control law,
90+
u(x,t) = -L*x # Form control law,
9191
t=0:h:5
9292
x0 = [1,0]
93-
y, t, x, uout = lsim(sys,u,t,x0)
94-
plot(t,x, lab=["Position", "Velocity"]', xlabel="Time [s]")
93+
y, t, x, uout = lsim(sys,u,t,x0=x0)
94+
plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")
9595
```
9696
"""
9797
function dlqr(A, B, Q, R)

0 commit comments

Comments
 (0)