Skip to content

Commit e197064

Browse files
committed
Merge branch 'defaultTimeFix'
2 parents fb94838 + 0a0622f commit e197064

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/timeresp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function _default_time_vector(sys::LTISystem, Tf::Real=-1)
231231
if Tf == -1
232232
Tf = 100*Ts
233233
end
234-
return linspace(0, Tf, round(Int, Tf/Ts))
234+
return 0:Ts:Tf
235235
end
236236

237237
function _default_Ts(sys::LTISystem)

test/test_timeresp.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ xreal[:,2,2] = -exp(-t).*t + exp(-t)
6666
xreal[:,3,2] = exp(-t).*t
6767
@test_approx_eq_eps x xreal 1e-14
6868

69+
70+
#Step response of discrete system with specified final time
71+
G = tf([1], [1; zeros(3)], 1)
72+
y, t2, x = step(G, 10)
73+
@test_approx_eq_eps y [zeros(3); ones(8)] 1e-14
74+
@test_approx_eq_eps t2 0:1:10 1e-14
75+
76+
#Impulse response of discrete system to final time that is not mulitple of the sample time
77+
G = tf([1], [1; zeros(3)], 0.3)
78+
y, t2, x = step(G, 2)
79+
@test_approx_eq_eps y [zeros(3); ones(4)] 1e-14
80+
@test_approx_eq_eps t2 0:0.3:1.8 1e-14
81+
82+
83+
6984
#Make sure t was never changed
7085
@test t0 == t
7186
end

0 commit comments

Comments
 (0)