From fb7042fc35ece6e7c066e597f616a77ae6376c10 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Fri, 18 Jun 2021 13:15:33 +0200 Subject: [PATCH] Yet another fix for struct_ctrb_states. Closes #475 (#541) --- src/simplification.jl | 2 +- test/test_simplification.jl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/simplification.jl b/src/simplification.jl index 44c398946..b406fd776 100644 --- a/src/simplification.jl +++ b/src/simplification.jl @@ -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 diff --git a/test/test_simplification.jl b/test/test_simplification.jl index 4689de8e7..c3387ec5c 100644 --- a/test/test_simplification.jl +++ b/test/test_simplification.jl @@ -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")