Skip to content

margin throws an error when the system has delay #941

@ronisbr

Description

@ronisbr

Consider the following system:

julia> C = 0.6 + 30 * tf([1, 0], [1])

julia> G = tf([0.04, 0.0001, 1.1], [1, 0.03, 254.9])

julia> H = tf([0.25], [1, 1, 0.25])

julia> L = C * G * H * delay(1)

If I try to obtain the margins using allMargins = false, I get the following error:

julia> margin(L)
ERROR: BoundsError: attempt to access 1-element Vector{Float64} at index [3]
Stacktrace:
 [1] throw_boundserror(A::Vector{Float64}, I::Tuple{Int64})
   @ Base ./essentials.jl:14
 [2] getindex
   @ ./essentials.jl:916 [inlined]
 [3] sisomargin(sys::DelayLtiSystem{Float64, Float64}, w::Vector{Float64}; full::Bool, allMargins::Bool)
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/kvrre/src/analysis.jl:463
 [4] sisomargin
   @ ~/.julia/packages/ControlSystemsBase/kvrre/src/analysis.jl:444 [inlined]
 [5] margin(sys::DelayLtiSystem{Float64, Float64}, w::Vector{Float64}; full::Bool, allMargins::Bool)
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/kvrre/src/analysis.jl:429
 [6] margin
   @ ~/.julia/packages/ControlSystemsBase/kvrre/src/analysis.jl:410 [inlined]
 [7] margin(system::DelayLtiSystem{Float64, Float64})
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/kvrre/src/analysis.jl:485
 [8] top-level scope
   @ REPL[12]:1

If works if I remove the delay or if I set allMargins = true:

julia> margin(L, allMargins = true)
(wgm = [[2.041402041527457, 11.081144646232188, 20.471831757852467, 26.741832375445096, 33.017521326540425, 39.2956993185886, 45.57529664743531, 51.85576981114693, 58.136836945502154, 64.41832383251091    263.7340285648331, 305.9620408928975, 347.7262613229265, 398.77747116198157, 429.0787275370144, 555.4392133863881, 566.1520203618901, 645.6860901815029, 661.8552898282388, 945.0001606654438];;], gm = [[77.50590739230606, 51.31234174534322, 28.63000544588986, 59.6816713967569, 86.52667289853684, 111.36432002593598, 135.07896681048322, 158.09878255883388, 180.65767674302057, 202.89464702435197    876.241336647831, 1017.3980298848596, 1156.9095606216863, 1327.3591877600206, 1428.4975273095072, 1850.1007378722575, 1885.8358956515124, 2151.1142359545875, 2205.040221748687, 3149.1992770654497];;], wpm = [Float64[];;], pm = [Float64[];;])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions