From 34a44b98f3e09c9a1a69c6fe169163cf4126757e Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Wed, 7 Oct 2026 04:19:51 +0000 Subject: [PATCH] Accept keyword arguments passed by the ControlSystemsBase 1.23 plot recipes for FRD The Bodeplot recipe passes balance to bode, and the frequency-vector selection passes adaptive to _default_freq_vector. Both are accepted and ignored for FRD. Co-Authored-By: Claude Opus 5.5 (1M context) --- Project.toml | 2 +- src/frd.jl | 6 +++--- test/test_plots.jl | 12 +++++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 504fd7a5..67ce11bd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ControlSystemIdentification" uuid = "3abffc1c-5106-53b7-b354-a47bfc086282" -version = "2.12.1" +version = "2.12.2" authors = ["baggepinnen "] [deps] diff --git a/src/frd.jl b/src/frd.jl index d968e57b..4591c95a 100644 --- a/src/frd.jl +++ b/src/frd.jl @@ -110,9 +110,9 @@ end ControlSystemsBase.noutputs(f::FRD) = f.r isa AbstractVector ? 1 : size(f.r, 1) ControlSystemsBase.ninputs(f::FRD) = f.r isa AbstractVector ? 1 : size(f.r, 2) -ControlSystemsBase._default_freq_vector(f::Vector{<:FRD}, _) = f[1].w -ControlSystemsBase._default_freq_vector(f::FRD, _) = f.w -function ControlSystemsBase.bode(f::FRD, w::AbstractVector = f.w; unwrap=true) +ControlSystemsBase._default_freq_vector(f::Vector{<:FRD}, _; kwargs...) = f[1].w +ControlSystemsBase._default_freq_vector(f::FRD, _; kwargs...) = f.w +function ControlSystemsBase.bode(f::FRD, w::AbstractVector = f.w; unwrap=true, kwargs...) # kwargs such as balance do not apply to frequency-response data w == f.w || error("Frequency vector must match the one stored in the FRD") angles = angle.(f.r) angles = reshape(angles, f.ny, f.nu, :) diff --git a/test/test_plots.jl b/test/test_plots.jl index ffbd4b93..be56ebda 100644 --- a/test/test_plots.jl +++ b/test/test_plots.jl @@ -21,4 +21,14 @@ welchplot(d) Gh,_ = tfest(d) plot(Gh, plotphase=true) -plot(tfest(d)) \ No newline at end of file +plot(tfest(d)) + +# FRD in the ControlSystemsBase plot recipes, which pass keyword arguments such as balance and adaptive +w = exp10.(LinRange(-1, 1, 50)) +frd = FRD(w, tf(1, [1, 1, 1])) +mag, phase, _ = bode(frd, w; unwrap=false, balance=true) +@test vec(mag) ≈ abs.(frd.r) +bodeplot(frd) +bodeplot([frd, frd]) +nyquistplot(frd) +sigmaplot(frd) \ No newline at end of file