Skip to content

Commit 34f8539

Browse files
authored
Merge pull request #700 from JuliaControl/Mt
add `Mt_circles` to `nyquistplot`
2 parents 3a92ba8 + 7aa0634 commit 34f8539

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/plotting.jl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,23 @@ end
292292

293293
@userplot Nyquistplot
294294
"""
295-
fig = nyquistplot(sys; Ms_circles=Float64[], unit_circle=false, hz=false, critical_point=-1, kwargs...)
296-
nyquistplot(LTISystem[sys1, sys2...]; Ms_circles=Float64[], unit_circle=false, hz=false, critical_point=-1, kwargs...)
295+
fig = nyquistplot(sys; Ms_circles=Float64[], Mt_circles=Float64[], unit_circle=false, hz=false, critical_point=-1, kwargs...)
296+
nyquistplot(LTISystem[sys1, sys2...]; Ms_circles=Float64[], Mt_circles=Float64[], unit_circle=false, hz=false, critical_point=-1, kwargs...)
297297
298298
Create a Nyquist plot of the `LTISystem`(s). A frequency vector `w` can be
299299
optionally provided.
300300
301-
- `unit_circle`: if the unit circle should be displayed
301+
- `unit_circle`: if the unit circle should be displayed. The Nyquist curve crosses the unit circle at the gain corssover frequency.
302302
- `Ms_circles`: draw circles corresponding to given levels of sensitivity (circles around -1 with radii `1/Ms`). `Ms_circles` can be supplied as a number or a vector of numbers. A design staying outside such a circle has a phase margin of at least `2asin(1/(2Ms))` rad and a gain margin of at least `Ms/(Ms-1)`.
303+
- `Mt_circles`: draw circles corresponding to given levels of complementary sensitivity. `Mt_circles` can be supplied as a number or a vector of numbers.
303304
- `critical_point`: point on real axis to mark as critical for encirclements
304305
305306
If `hz=true`, the hover information will be displayed in Hertz, the input frequency vector is still treated as rad/s.
306307
307308
`kwargs` is sent as argument to plot.
308309
"""
309310
nyquistplot
310-
@recipe function nyquistplot(p::Nyquistplot; Ms_circles=Float64[], unit_circle=false, hz=false, critical_point=-1)
311+
@recipe function nyquistplot(p::Nyquistplot; Ms_circles=Float64[], Mt_circles=Float64[], unit_circle=false, hz=false, critical_point=-1)
311312
systems, w = _processfreqplot(Val{:nyquist}(), p.args...)
312313
ny, nu = size(systems[1])
313314
nw = length(w)
@@ -354,6 +355,21 @@ nyquistplot
354355
label := "Ms = $(round(Ms, digits=2))"
355356
(-1 .+ (1/Ms) * C, (1/Ms) * S)
356357
end
358+
end
359+
for Mt in Mt_circles
360+
@series begin
361+
subplot --> s2i(i,j)
362+
primary := false
363+
linestyle := :dash
364+
linecolor := :gray
365+
seriestype := :path
366+
markershape := :none
367+
label := "Mt = $(round(Mt, digits=2))"
368+
(-1 .+ (1/Mt) * C, (1/Mt) * S)
369+
ct = -Mt^2/(Mt^2-1) # Mt center
370+
rt = Mt/(Mt^2-1) # Mt radius
371+
ct.+rt.*C, rt.*S
372+
end
357373
end
358374
if unit_circle
359375
@series begin

test/test_plots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getexamples()
1515
setPlotScale("dB")
1616
bodeplot(sys,ws)
1717
end
18-
nyquistgen() = nyquistplot(sysss,ws)
18+
nyquistgen() = nyquistplot(sysss,ws, Ms_circles=1.2, Mt_circles=1.2)
1919
sigmagen() = sigmaplot(sysss,ws)
2020
#Only siso for now
2121
nicholsgen() = nicholsplot(tf1,ws)

0 commit comments

Comments
 (0)