Skip to content

Commit

Permalink
Fix Bode plot with zero magnitude
Browse files Browse the repository at this point in the history
Closes #438
  • Loading branch information
baggepinnen committed Dec 15, 2023
1 parent e8f68d6 commit 5360a25
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

Check warning on line 299 in lib/ControlSystemsBase/src/plotting.jl

View check run for this annotation

Codecov / codecov/patch

lib/ControlSystemsBase/src/plotting.jl#L299

Added line #L299 was not covered by tests
end

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

0 comments on commit 5360a25

Please sign in to comment.