0
$\begingroup$

I need to program a transfer function T(s) = 1/(s^2+Bs+1) and simulate the response of a unit step input of the Force for each value of B which i used in my range my B values are 4,2,1.8,1.4.......

tfm = TransferFunctionModel[(1)/(s^2 + Bs + 1), s];
tfm[I Range[4,2,1.8,1.4,1,0.6,0.2,0.02]]
Plot[Abs[tfm[I f]], {f, 0, 5}]

What am I doing wrong?

$\endgroup$
  • $\begingroup$ For one thing, you are not using Range correctly. Note the error: Range called with 8 arguments; between 1 and 3 arguments are expected. $\endgroup$ – bill s Feb 9 at 18:37
1
$\begingroup$

Something to get you started. Added stiffness as well, which you could always set to 1.

enter image description here

Clear["Global`*"];

Manipulate[
 Module[{tf, y, t},
  tf = TransferFunctionModel[1/(s^2 + b s + k), s];

  (*specific time forces numeric, much faster*)
  y = OutputResponse[tf, UnitStep[t], {t, 0, 50}]; 

  Plot[Evaluate@y, {t, 0, 50}, PlotRange -> {{0, 50}, {-.1, 2}}, 
     Frame -> True, 
     FrameLabel -> {{"y(t)", None}, {"t", "step response"}}, 
     GridLines -> Automatic, GridLinesStyle -> Dashed, 
     ImageSize -> {300, 300}, PlotStyle -> Red, AspectRatio -> 1]
  ],

 (*controls*)
 Grid[{
   {Row[{"Damping B: ", PopupMenu[Dynamic[b], {0.02, 4, 2, 1.8, 1.4, 1, 0.6, 0.2}]}]},
   {Row[{"Stiffness k ", Manipulator[Dynamic[k, {k = #} &], {1, 5, .1}, 
       ImageSize -> Tiny], Dynamic[k]}]}
   }
  ],
 ContinuousAction -> False,
 TrackedSymbols :> {b, k}
 ]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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