Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bode plot with zero magnitude #911

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
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 @@
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
Loading