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

Building a vector of both continuous and discrete #665

Open
albheim opened this issue Mar 8, 2022 · 2 comments
Open

Building a vector of both continuous and discrete #665

albheim opened this issue Mar 8, 2022 · 2 comments
Labels
v1 Issues to resolve before releasing v1

Comments

@albheim
Copy link
Member

albheim commented Mar 8, 2022

Noticed that plotting by sending in a vector of plots does not seem to work when there is a mix of discrete and continuous, but when sending them in one by one it works nicely. Have not looked into it at all, just felt it should probably be possible to do, so thought I could put it up here.

julia> G = tf([0.1, 0], [0.1, 1]);

julia> H = c2d(G, 0.01, :fwdeuler);

julia> bodeplot([G, H])
ERROR: Sampling time mismatch
Stacktrace:
 [1] promote_rule(#unused#::Type{Discrete{Float64}}, #unused#::Type{Continuous})
   @ ControlSystems ~/.julia/packages/ControlSystems/lbxGy/src/types/TimeEvolution.jl:31
 [2] promote_type
   @ ./promotion.jl:289 [inlined]
 [3] promote_rule(#unused#::Type{TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}}, #unused#::Type{TransferFunction{Discrete{Float64}, ControlSystems.SisoRational{Float64}}})
   @ ControlSystems ~/.julia/packages/ControlSystems/lbxGy/src/types/promotion.jl:36
 [4] promote_type
   @ ./promotion.jl:289 [inlined]
 [5] promote_typeof(x::TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}, xs::TransferFunction{Discrete{Float64}, ControlSystems.SisoRational{Float64}})
   @ Base ./promotion.jl:330
 [6] vect(::TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}, ::Vararg{Any})
   @ Base ./array.jl:144
 [7] top-level scope
   @ REPL[8]:1

julia> bodeplot(G)

julia> bodeplot!(H) # Works nicely
@baggepinnen baggepinnen changed the title Plotting continuous and discrete in same plot Building a vector of both continuous and discrete Mar 8, 2022
@baggepinnen
Copy link
Member

baggepinnen commented Mar 8, 2022

The problem is not the plot, it's the creation of the vector

julia> G = tf([0.1, 0], [0.1, 1]);

julia> H = c2d(G, 0.01, :fwdeuler);

julia> [G, H]
ERROR: Sampling time mismatch
Stacktrace:
 [1] promote_rule(#unused#::Type{Discrete{Float64}}, #unused#::Type{Continuous})
   @ ControlSystems ~/.julia/dev/ControlSystems/src/types/TimeEvolution.jl:31
 [2] promote_type
   @ ./promotion.jl:289 [inlined]
 [3] promote_rule(#unused#::Type{TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}}, #unused#::Type{TransferFunction{Discrete{Float64}, ControlSystems.SisoRational{Float64}}})
   @ ControlSystems ~/.julia/dev/ControlSystems/src/types/promotion.jl:36
 [4] promote_type
   @ ./promotion.jl:289 [inlined]
 [5] promote_typeof(x::TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}, xs::TransferFunction{Discrete{Float64}, ControlSystems.SisoRational{Float64}})
   @ Base ./promotion.jl:330
 [6] vect(::TransferFunction{Continuous, ControlSystems.SisoRational{Float64}}, ::Vararg{Any})
   @ Base ./array.jl:144
 [7] top-level scope
   @ REPL[12]:1

The following works

julia> TransferFunction[G, H]
2-element Vector{TransferFunction}:

@baggepinnen
Copy link
Member

I have also been bothered by our handling of of vect and cat etc., it's sometimes inconventient to build arrays of systems without forming a single MIMO system, might be worth spending some time to figure out best practices here before 1.0

@baggepinnen baggepinnen added the v1 Issues to resolve before releasing v1 label Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1 Issues to resolve before releasing v1
Projects
None yet
Development

No branches or pull requests

2 participants