2
$\begingroup$

I want to plot the output response of a system with gain, first-order lag and time delay, where the transfer function is

tf = 2 Exp[-0.1 s]/(.1 + s)

To plot a time delay, we need to use an approximation, as Mathematica's TransferFunctionModel is restricted to rational transfer functions. We can use a Padé approximation

pa = PadeApproximant[tf, {s, 0, 5}]

and then determine the output response and plot it using

model = TransferFunctionModel[pa, s]
output = OutputResponse[model, UnitStep[t], t];
Plot[output, {t, 0, 10}, PlotRange -> All]

My output response looks very weird:

time delay plot

Can somebody please explain to me what I'm doing wrong?

$\endgroup$
2
  • 1
    $\begingroup$ most likely the function is complex in that interval $\endgroup$
    – chris
    Commented Oct 26, 2012 at 9:45
  • $\begingroup$ b.t.w welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` $\endgroup$
    – chris
    Commented Oct 26, 2012 at 14:24

1 Answer 1

3
$\begingroup$

If you add Chop to your output:

output = OutputResponse[model, UnitStep[t], t] // Chop
Plot[output, {t, 0, 10}, PlotRange -> All]

you will get

Mathematica graphics

which is quite different. Chop removes small (in your case imaginary) roundoff errors. At this stage though I would try and make sure the result actually makes sense. These roundoff errors are slightly suspicious. One test you can do is ask for higher precision in the computation, via say

pa = PadeApproximant[tf, {s, 0, 5}]//N[#,20]&

which in this context seems to produce the same solution.

$\endgroup$
2
  • $\begingroup$ I was thinking the gap might have something to do with an imaginary component, but I tried using Re[], which didn't help that much. Thanks for introducing me to Chop! $\endgroup$
    – Gerrit
    Commented Oct 26, 2012 at 14:29
  • $\begingroup$ If I were you I would do a few tests to make sure the answer is correct though. The fact that you need to use Chop is an indication that your result might not be very robust. $\endgroup$
    – chris
    Commented Oct 26, 2012 at 14:39

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.