Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions lib/ControlSystemsBase/src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,20 @@ end
label := @sprintf("Final value: %.3f", si.yf)
[si.yf]
end
@series begin
linestyle := :solid
linewidth --> 2
color --> 2
label := @sprintf("Rise time: %.3f", si.risetime)
si.res.t[si.i10:si.i90], si.res.y[1, si.i10:si.i90]
end
@series begin
color --> 2
seriestype := :vline
label := @sprintf("Rise time threshold: %.1f%%-%.1f%%", 100si.risetime_th[1], 100si.risetime_th[2])
[si.res.t[si.i10], si.res.t[si.i90]]
if si.i10 > 0 && si.i90 > 0
@series begin
linestyle := :solid
linewidth --> 2
color --> 2
label := @sprintf("Rise time: %.3f", si.risetime)
si.res.t[si.i10:si.i90], si.res.y[1, si.i10:si.i90]
end
@series begin
color --> 2
seriestype := :vline
label := @sprintf("Rise time threshold: %.1f%%-%.1f%%", 100si.risetime_th[1], 100si.risetime_th[2])
[si.res.t[si.i10], si.res.t[si.i90]]
end
end
@series begin
color --> 3
Expand Down
9 changes: 8 additions & 1 deletion lib/ControlSystemsBase/src/timeresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,14 @@ function stepinfo(res::SimResult; y0 = nothing, yf = nothing, settling_th = 0.02
op = direction == 1 ? (>) : (<)
i10 = findfirst(op.(y, y0 + risetime_th[1] * stepsize * direction))
i90 = findfirst(op.(y, y0 + risetime_th[2] * stepsize * direction))
risetime = res.t[i90] - res.t[i10]
if i10 === nothing || i90 === nothing
@warn "Response did not reach the requested risetime threshold(s) within the simulation window"
i10 = i10 === nothing ? 0 : i10
i90 = i90 === nothing ? 0 : i90
risetime = oftype(float(res.t[1]), NaN)
else
risetime = res.t[i90] - res.t[i10]
end
StepInfo(y0, yf, stepsize, peak, peaktime, overshoot, lowerpeak, lowerpeakind, undershoot, settlingtime, settlingtimeind, risetime, i10, i90, res, settling_th, risetime_th)
end

Expand Down
Loading