Skip to content

Commit

Permalink
Merge pull request #926 from JuliaControl/truncerror
Browse files Browse the repository at this point in the history
more helpful error message in baltrunc
  • Loading branch information
baggepinnen authored May 10, 2024
2 parents 475758a + f15edfe commit 4544091
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/src/examples/tuning_from_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ gangoffourplot(P, CF)

The gang of four indicates that we have a robust tuning, no uncomfortably large peaks appears in either ``T`` or ``S``.

Below, we attempt a pole-placement design for comparison. Contrary to the PID controller, a pole-placement controller _can_ place all poles of this system arbitrarily (the system is _controllable_, which can be verified using the function [`controllability`](@ref)).
Below, we attempt a pole-placement design for comparison. Contrary to the PID controller, a state-feedback controller designed using pole placement _can_ place all poles of this system arbitrarily (the system is _controllable_, which can be verified using the function [`controllability`](@ref)).


## Pole placement
Expand Down
5 changes: 5 additions & 0 deletions lib/ControlSystemsBase/src/matrix_comps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ function baltrunc(sys::ST; atol = sqrt(eps()), rtol = 1e-3, n = nothing, residua
S = S[S .>= S[1]*rtol]
n = length(S)
else
n > sys.nx && error("n too large. A state dimension of n = $n was requested, but the original system has a $(sys.nx)-dimensional state.")
if length(S) < n
@error("n too large. A state dimension of n = $n was requested, but after a balanced realization was computed only $(length(S)) dimensions remain. Try either calling `minreal` before calling `baltrunc`, or try balancing the model using `balance_statespace`. Returning a system with n = $(length(S))")
n = length(S)
end
S = S[1:n]
end
i1 = 1:n
Expand Down

0 comments on commit 4544091

Please sign in to comment.