2
$\begingroup$

I've got the following transfer function (in the s-domain):

$$\text{H}(s)=\frac{\text{C}s}{\text{RC}s+1}$$

Is there a function in Mathematica 10 that I can go back to the differential equation (in the t-domain), I've looked for it but I'm not be able to find it?

Thanks in advance

$\endgroup$
1
  • $\begingroup$ This would benefit from addition of Mathematica code at least for the definition of the function in question. $\endgroup$ Nov 29, 2015 at 20:13

2 Answers 2

3
$\begingroup$

You can use the definition of Laplace. Assuming zero initial conditions, replace $s$ with $\frac{dy}{dt}$ and $s^2$ with $\frac{d^2y}{dt^2}$ and so on.

tfToDiff[tf_, s_, t_, y_, u_] := Module[{rhs, lhs, n, m},
  rhs = Numerator[tf];
  lhs = Denominator[tf];
  rhs = rhs /. m_. s^n_. -> m D[u[t], {t, n}];
  lhs = lhs /. m_. s^n_. -> m D[y[t], {t, n}];
  lhs == rhs
  ]

Now call it

tf = C0 s/(R0 C0 s + 1);
eq=tfToDiff[tf, s, t, y, u]

Mathematica graphics

$y(t)$ is your output, and $u(t)$ is the input. (these are what go in the transfer function when you write $\frac{Y(s)}{U(s)}=\dots$. You'd have to replace this when the actual $u(t)$ to solve the differential equation. For step input, (i.e. $u(t)=\text{unit step}$)

eq = eq /. u'[t] -> UnitStep'[t];
DSolve[{eq, y[0] == 0}, y[t], t]

Mathematica graphics

Another Example

tf = (5 s)/(s^2 + 4 s + 25);
tfToDiff[tf, s, t, y, u]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Your last Example gives me nothing, how can I make it work? I jsut copied your code $\endgroup$ Nov 29, 2015 at 21:09
  • $\begingroup$ @JanEerland You need to have the function tfToDiff defined first. $\endgroup$
    – Nasser
    Nov 29, 2015 at 21:10
  • $\begingroup$ How can I do that? $\endgroup$ Nov 29, 2015 at 21:10
  • $\begingroup$ Yes, of course I got it, thanks a lot! $\endgroup$ Nov 29, 2015 at 21:13
4
$\begingroup$

Depending on what you want to do with it, you might use the built-in InverseLaplaceTransform:

InverseLaplaceTransform[c s/(1 + r c s), s, t]

c (-(E^(-(t/(c r)))/(c^2 r^2)) + DiracDelta[t]/(c r))
$\endgroup$
0

Your Answer

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

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