Skip to content

Commit 4699bfe

Browse files
authored
Merge pull request #722 from JuliaControl/tfs
allow char when creating tf(s)
2 parents 880a9d6 + 5b088d2 commit 4699bfe

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/types/tf.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ function tf(G::TransferFunction{TE,<:SisoTf{T}}) where {TE<:TimeEvolution,T<:Num
7272
end
7373

7474
# Function for creation of 's' or 'z' var
75-
function tf(var::AbstractString)
76-
var != "s" && error("""var must be 's' for continuous time tf. Call tf("z", Ts) for a discrete-time variable.""")
75+
function tf(var::Union{AbstractString, Char})
76+
var ("s", 's') && error("""var must be 's' for continuous time tf. Call tf("z", Ts) for a discrete-time variable.""")
7777
return tf([1, 0], [1], Continuous())
7878
end
79-
function tf(var::AbstractString, Ts::Real)
80-
var != "z" && error("var must be 'z' for discrete-time tf.")
79+
function tf(var::Union{AbstractString, Char}, Ts::Real)
80+
var ("z", 'z') && error("var must be 'z' for discrete-time tf.")
8181
Ts == 0 && error("Ts must not be 0 for discrete-time tf.")
8282
return tf([1, 0], [1], Discrete(Ts))
8383
end

test/test_transferfunction.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# type: C: Continuous, D: Discrete
66
# dims: "npnuny" (np = # poles)
77
s = tf("s")
8+
@test s == tf('s')
89
@inferred 1.0/s
910
@inferred 1/s
1011

@@ -16,6 +17,7 @@ C_221 = @inferred tf(vecarray(1, 2,[1, 2, 3], [1, 2]), vecarray(1, 2, [1, 8, 15]
1617
C_222 = [C_221; C_221]
1718
C_022 = @inferred tf(4*[1 0; 0 1])
1819
s = @inferred tf("s")
20+
s = @inferred tf('s')
1921

2022
# DISCRETE
2123
D_111 = @inferred tf([1, 2], [1, -0.5], 0.005)

0 commit comments

Comments
 (0)