Skip to content

Commit

Permalink
Merge pull request #911 from JuliaControl/discbodefix
Browse files Browse the repository at this point in the history
Fix Bode plot with zero magnitude
  • Loading branch information
baggepinnen committed Dec 15, 2023
2 parents e8f68d6 + 5360a25 commit ecd97f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ControlSystemsBase/src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,11 @@ end
else
sbal = s
end
mag, phase = bode(sbal, w; unwrap=false)[1:2]
mag, phase = bode(sbal, w; unwrap=false)
if _PlotScale == "dB" # Set by setPlotScale(str) globally
mag = 20*log10.(mag)
elseif 0 mag
replace!(mag, 0 => -Inf) # To prevent plot crashing when some magnitude is exactly zero
end

xlab = plotphase ? "" : (hz ? "Frequency [Hz]" : "Frequency [rad/s]")
Expand Down

0 comments on commit ecd97f3

Please sign in to comment.