Skip to content

Commit

Permalink
Yet another fix for struct_ctrb_states. Closes #475 (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen authored Jun 18, 2021
1 parent 714bf85 commit fb7042f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/simplification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function struct_ctrb_states(A::AbstractVecOrMat, B::AbstractVecOrMat)
bitA = A .!= 0
x = vec(any(B .!= 0, dims=2)) # index vector indicating states that have been affected by input
for i = 1:size(A, 1) # apply A nx times, similar to controllability matrix
x = (bitA * x) .!= 0
x = x .| (bitA * x) .!= 0
end
x
end
14 changes: 14 additions & 0 deletions test/test_simplification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ using ControlSystems.DemoSystems: resonant
R = resonant()*resonant()
@test sminreal(R) == R # https://github.com/JuliaControl/ControlSystems.jl/issues/409

# https://github.com/JuliaControl/ControlSystems.jl/issues/475
A = [
0.0 0.0 0.0;
1.0 0.0 -0.00578297;
0.0 1.0 0.0;
]
B = [1.0; 0.0; 0.0]
C = [0.0 0.0 1.0]
D = [0]

ss_sys = ss(A,B,C,D)
@test sminreal(ss_sys) == ss_sys


## MINREAL ##

s = tf("s")
Expand Down

0 comments on commit fb7042f

Please sign in to comment.