1

I've found scipy.signal.dstep, scipy.signal.dlsim functions that help simulate behavior of a transfer function, for example: signal.dlsim(signal.cont2discrete(([1], [1, 1]), 0.1), u=[1, 1], t=[0.0, 0.1]) allows to model 1/(s+1) function in [0, 0.1] time interval with control signal with value 1. But these functions do not allow to model just one step with initial values.

Are there any other functions that allow to model one step of a transfer function or how it's better to do it?

rdo
  • 3,872
  • 6
  • 34
  • 51

1 Answers1

2

First of all, i'm not sure, if you want to use discrete time or continuous time, because you're using s operator for cont. time, the functions dstep and dlsim are used for discrete time representation. However, i used the continuous one in my example.

You can create a dlti object in python with scipy.signal's lti function. The created filter object has a method step where the first parameter is used for the initial time vector. lti.step So you can plot your step response with this snippet.

import scipy.signal as sig
import matplotlib.pyplot as plt

filt = sig.lti(1, (1,1))

plt.plot(*filt.step())
plt.plot(*filt.step(-1))
plt.show()

If you don't want to plot them, simply call

t, a = filt.step()
Franz Forstmayr
  • 1,219
  • 1
  • 15
  • 31
  • Thank you for the answer, but I meant that I need a function that gives me not a series of output values but just one. I mean that I can call it like `t1, y1, state1 = one_step(filt, state0)` and after `t2, y2, state2 = one_step(filt, state1)` – rdo Dec 28 '18 at 21:36
  • 1
    but anyway I found an answer: `_, yout, xout = signal.lsim(tf, U=[self_u, u], T=[0., .1], X0=x0)` and sequentially call it – rdo Dec 28 '18 at 21:44