From 5360a25f972a94fb92ce2d038224a541553601cb Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Fri, 15 Dec 2023 06:23:57 +0100 Subject: [PATCH] Fix Bode plot with zero magnitude Closes #438 --- lib/ControlSystemsBase/src/plotting.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ControlSystemsBase/src/plotting.jl b/lib/ControlSystemsBase/src/plotting.jl index e4f62ea0c..667567266 100644 --- a/lib/ControlSystemsBase/src/plotting.jl +++ b/lib/ControlSystemsBase/src/plotting.jl @@ -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]")