Skip to content

Commit

Permalink
better error messages for failed inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Dec 6, 2023
1 parent b51adf7 commit 2b41c29
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ControlSystemsBase/src/types/StateSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,11 @@ end
function /(n::Number, sys::ST) where ST <: AbstractStateSpace
# Ensure s.D is invertible
A, B, C, D = ssdata(sys)
LinearAlgebra.checksquare(D) || error("The inverted system must have the same number of inputs and outputs")
Dinv = try
inv(D)
catch
error("D isn't invertible")
error("D isn't invertible. If you are trying to form a quotient between two systems `N(s) / D(s)` where the quotient is proper but the inverse of `D(s)` isn't, consider calling `N / D` instead of `N * inv(D)")
end
return basetype(ST)(A - B*Dinv*C, B*Dinv, -n*Dinv*C, n*Dinv, sys.timeevol)
end
Expand Down

0 comments on commit 2b41c29

Please sign in to comment.