1
$\begingroup$

I have transfer function:

$W=\frac{1}{s+1}$

tf = TransferFunctionModel[{{1/(s + 1)}}, s]
BodePlot[tf, {.01, 100}]

It is very simple to construct a Bode diagram, but how to calculate the amplitude and phase shift with the help of 'BodePlot' at a selected frequency, for example $\omega=2\pi$, is not clear...

Will be glad to advice.

$\endgroup$

3 Answers 3

3
$\begingroup$
tf = TransferFunctionModel[{{1/(s + 1)}}, s];
freqs = {{π, 2 π}};

BodePlot[tf, {.01, 100}, Mesh -> Table[freqs, 2], 
   MeshStyle -> Directive[PointSize[Medium], Red]]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you for your answer. Your solution is good for charting. It was interesting for me to calculate the magnitude and phase for the selected frequency. Please see my solution. mathematica.stackexchange.com/a/249543/67019 $\endgroup$
    – ayr
    Commented Jun 13, 2021 at 16:38
  • 2
    $\begingroup$ That's what Mesh does - compute the magnitude and phase at the selected frequency. Also see how to get the coordinates for points in a plot. $\endgroup$ Commented Jun 14, 2021 at 0:13
  • $\begingroup$ well, ok, it's good solution too, why not :) $\endgroup$
    – ayr
    Commented Jun 14, 2021 at 6:50
4
$\begingroup$

An example:

ss = StateSpaceModel[{3 y''[t] - 2 y[t] == u[t] + u'[t]}, {y[t], y'[t]}, {u[t]}, y[t], t];
tf = TransferFunctionModel[ss, s];

points = {Log10@#,20*Log10@Abs@tf[\[ImaginaryJ] #][[1, 1]]} & /@ {0.1, 1, 10} // N;

BodePlot[ss, {0.01, 100}, ImageSize -> 300, GridLines -> Automatic, 
 Epilog -> {PointSize[Medium], Red, Point[points]}, PlotLayout -> "Magnitude"]

enter image description here

I have added the Phaseplot

pointsArg = {Log10@#,Arg@tf[\[ImaginaryJ] #][[1, 1]]*180/\[Pi]} & /@ {0.1, 1, 10} // N;

BodePlot[ss, {0.01, 100}, ImageSize -> 300, GridLines -> Automatic, 
 Epilog -> {PointSize[Medium], Red, Point[pointsArg]}, PlotLayout -> "Phase"]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ @dtn Do the calculation as I demonstrated. Replace only tf with 1/(1+s). $\endgroup$
    – rmw
    Commented Jun 12, 2021 at 12:52
  • $\begingroup$ Nice solution, thank you! See also my answer. $\endgroup$
    – ayr
    Commented Jun 12, 2021 at 12:56
0
$\begingroup$

Very simple solution and using Bode plot

fr = ReplaceAll[1/(s + 1), s -> Sqrt[-1] \[Omega]];

LogLinearPlot[20 Log10[Abs[fr]], {\[Omega], 0.001, 100}, 
  PlotRange -> All];

LogLinearPlot[Arg[fr], {\[Omega], 0.001, 100}, PlotRange -> Full];

\[Omega] = 2 Pi;

N[Abs[fr]];

N[Arg[fr]];
$\endgroup$

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.