First at all, this is trictly related to my own question: How to transform transfer functions into differential equations?

How can I transfer my differential equation into a transfer function?

For me (at the moment) the following works:

TimeDomain2TransferFunction[eqn_, y0_, u0_] :=
    LaplaceTransform[eqn, t, s] /. y0 /. 
      u0 /. {LaplaceTransform[y[t], t, s] -> Y[s], 
      LaplaceTransform[u[t], t, s] -> U[s]}
    , Y[s]][[1, 1, 2]]/U[s]

So, let's say the differential equation is

sysEq = y'''[t] == -1/T2^2 y'[t] - T1/T2^2 y''[t] + Ki/T2^2 u[t]

Then the following gives me an satisfying result:

TimeDomain2TransferFunction[sysEq, {y[0] -> 0, y'[0] -> 0, 
  y''[0] -> 0}, {}]

Out: $\frac{\text{Ki}}{s \left(s^2 \text{T2}^2+s \text{T1}+1\right)}$

Out: $\frac{\text{Ki}}{s^3 \text{T2}^2+s^2 \text{T1}+s}$

Is there a more elegant way to do this? For example, for different letters (not only y and u).


3 Answers 3


Is there a more elegant way to do this?

Why not just use the control system functions as is for this? create state space sys from the DE and then use TransferFunctionModel[sys] to obtain the tf:

sysEq = y'''[t] == -1/T2^2 y'[t] - T1/T2^2 y''[t] + ki/T2^2 u[t];
sys = StateSpaceModel[sysEq, {{y[t], 0}}, {{u[t], 0}}, {y[t]}, t];

Mathematica graphics

  • $\begingroup$ Well, that's a good question. I thought there was a reason (because I know these functions), but I can't find it anymore. So, due to the fact that it works for all my systems and it's no hidden function, I prefere your solution. $\endgroup$
    – Phab
    Sep 4, 2014 at 7:53
  • $\begingroup$ Seems like it doesn't work with version 10.2 $\endgroup$
    – Phab
    Aug 4, 2015 at 6:59
  • $\begingroup$ @Phab I do not have 10.2, but I just tried it on 10.1 and it works: !Mathematica graphics so I really do not know why it would not work in 10.2. I am waiting for version 11 before I upgrade again. $\endgroup$
    – Nasser
    Aug 4, 2015 at 7:50
  • $\begingroup$ "Found" the reason why: It's a bug since 10.0.2. $\endgroup$
    – Phab
    Aug 5, 2015 at 5:34

There's an internal function that does this:

Control`DEqns`transferfunctionForm[sysEq, {{y[t], 0}}, {{u[t], 0}}, 
 y[t], t, s]

The syntax is just like that for the conversion of differential equations to StateSpaceModel, except for an additional last argument that specifies the Laplace variable.

(It doesn't seem to work with delay systems, and for difference equations you need to explicitly specify the sampling period, eg,

 y[t + 1] + y[t] == u[t], {{y[t], 0}}, {{u[t], 0}}, y[t], t, z, 
 SamplingPeriod -> T]


  • $\begingroup$ with the exception of the delayed systems, great solution! Where do you/can I find this internal functions? $\endgroup$
    – Phab
    Aug 21, 2014 at 6:15
  • $\begingroup$ These are undocumented, so naturally the best way to hear about them is on sites such as these. $\endgroup$ Aug 21, 2014 at 14:21

This is not bulletproof but its simpler :-)

eq2 = sysEq /. Derivative[n_][a_][b_] -> s^n a[s]

s^3 y(s) == -((s^2 T1 y(s))/T2^2) - (s y(s))/T2^2 + (χ u(t))/T2^2

First@First@Solve[eq2, y[s]] /. _[t] -> 1

(* ==> y(s) -> χ/(s (s^2 T2^2 + s T1 + 1)) *)
  • $\begingroup$ fails on y[t] == Kp u[t] (also on delayed systems). Also it's not the correct way with replacing u[t] by 1 I think. But interesting syntax, never saw before. $\endgroup$
    – Phab
    Aug 21, 2014 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.