Working with the recent stepplot() changes in ControlSystems.jl

I am trying to run the example usage code provided in the README.md file of the ControlSystems.jl repository, but with the recent changes, it seems impossible to produce exactly the same stepplot() results with plot(step()) as the recent changes note suggests.

As another specific use example, how would one use the new replacement for stepplot() in the following?

using ControlSystems 
using Plots
pyplot()

M = 7
K = 2.8
fv = [1.5 5 20]
wn = sqrt(K/M)
zetas = fv ./ (M * 2 * wn) 
G = [ tf([wn^2], [1, 2*zeta*wn, wn^2]) for zeta in zetas ]
t = 0:0.01:40

stepplot(G, t, lw=3,  label=[L"F_v="*"$(fv[1])" L"F_v="*"$(fv[2])" L"F_v="*"$(fv[3])"])

Thanks.

Hey and welcome to the community! Thanks for pointing out the problem in the readme, I’ll fix it.

There are no plot recipes for vectors of SimResult at the moment, but such recipes should perhaps be added.
Your example would currently look like this

M = 7
K = 2.8
fv = [1.5, 5, 20]
wn = sqrt(K/M)
zetas = fv ./ (M * 2 * wn) 
G = [ tf([wn^2], [1, 2*zeta*wn, wn^2]) for zeta in zetas ]
t = 0:0.01:40

plot()
for (G, lab) in zip(G, ["F_v="*"$(fv[1])" "F_v="*"$(fv[2])" "F_v="*"$(fv[3])"])
    plot!(step(G, t); lw=3, lab)
end
display(current())
2 Likes

https://github.com/JuliaControl/ControlSystems.jl/pull/594
you’ll soon be able to plot a vector of SimResult rather than writing a loop, then your example will be

plot(step.(G, Ref(t)); lw=3, label=["F_v="*"$(fv[1])" "F_v="*"$(fv[2])" "F_v="*"$(fv[3])"])
4 Likes