Skip to content

Commit

Permalink
split into methods
Browse files Browse the repository at this point in the history
  • Loading branch information
albheim committed May 26, 2021
1 parent ac27fac commit af93712
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,16 @@ function c2d_poly2poly(p, Ts)
return real(Polynomials.poly(exp(ro .* Ts)).coeffs[end:-1:1])
end

function c2d(G::TransferFunction{<:Continuous, <:SisoRational}, Ts, args...; kwargs...)
issiso(G) || error("c2d(G::TransferFunction, h) not implemented for MIMO systems")
sysd = c2d(ss(G), Ts, args...; kwargs...)
return convert(TransferFunction{typeof(sysd.timeevol), SisoRational}, sysd)
end

function c2d(G::TransferFunction{<:Continuous, T}, Ts, args...; kwargs...) where {T}
function c2d(G::TransferFunction{<:Continuous, <:SisoZpk}, Ts, args...; kwargs...)
issiso(G) || error("c2d(G::TransferFunction, h) not implemented for MIMO systems")
sys = ss(G)
sysd = c2d(sys, Ts, args...; kwargs...)
# Extract the basic type (SisoRational/SisoZpk) without the parametric values
# This allows the parametric type promotion to be handled by convert
BT = Base.typename(T).wrapper
return convert(TransferFunction{typeof(sysd.timeevol), BT}, sysd)
sysd = c2d(ss(G), Ts, args...; kwargs...)
return convert(TransferFunction{typeof(sysd.timeevol), SisoZpk}, sysd)
end

"""
Expand Down

0 comments on commit af93712

Please sign in to comment.