2
$\begingroup$

The webpage on Manipulate provides an example on section Examples > Applications of how to manipulate two parameters (the initial conditions) of an Initial Value Problem (ODE with initial conditions), which is the following (I've removed Epilog and ImagePadding because they're not interesting):

Example

Instead of plotting the solution to an ODE, I'd like to plot the step response of a system given its transfer function. The transfer function is:

$\dfrac{\dfrac{5}{s^2+2s} K_1}{1+\dfrac{5}{s^2+2s} (K_2 s+K_1)} \tag*{}$

where $K_1$ and $K_2$ are the parameters I want to manipulate. So, tried to change Evaluate with the following code:

OutputResponse[TransferFunctionModel[(5/(s^2 + 2 s)*K1)/(1 + 5/(s^2 + 2 s)*(K2*s + K1)), s], UnitStep[t], {t, 0, 10}] 

but Mathematica doesn't show the plot:

My attempt

What's wrong? What would be the appropriate code?

$\endgroup$
1
  • $\begingroup$ This works:Manipulate[ fun = OutputResponse[ TransferFunctionModel[(5/(s^2 + 2 s)*K1)/(1 + 5/(s^2 + 2 s)*(K2*s + K1)), s] , UnitStep[t], {t, 0, 10}][[1]]; Print[fun]; Plot[fun, {t, 0, 4}] , {{K1, 1}, 0, 3}, {{K2, 1}, 0, 3}] $\endgroup$ Commented Nov 7, 2020 at 14:50

1 Answer 1

5
$\begingroup$
Manipulate[Plot[Evaluate@ OutputResponse[TransferFunctionModel[(5/(s^2 + 2 s)*K1)/(1 + 5/(s^2 + 2 s)*(K2*s + K1)), s], UnitStep[t], {t, 0, 10}], {t, 0, 4}, PlotRange -> {0, 3}], {{K1, 1}, 0, 3}, {{K2, 2}, 0, 3}] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.