2
$\begingroup$

Any idea why this PhaseRange does not work?

BodePlot[-(1/(s + 1000)), PlotLayout -> "Phase", 
 PhaseRange -> {0, 2 \[Pi]}]

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ The values on the y-axis on the left are in degree, while the PhaseRange option is specified in radians. So only if the phase would exceed -360 in your plot, the PhaseRange option would take effect. $\endgroup$
    – Mathias
    Commented Feb 28, 2022 at 8:07
  • $\begingroup$ @Mathias PhaseRange -> {-180, 180} doesn't work either. Why does it need the phase exceeding -360 for the option to be effective? I don't quite get it. $\endgroup$
    – hana
    Commented Feb 28, 2022 at 9:00
  • $\begingroup$ What if I want the phase to start at 180 degree instead? What setting should I use? $\endgroup$
    – hana
    Commented Feb 28, 2022 at 9:26
  • $\begingroup$ A canonical sample of a "minimal working example". $\endgroup$
    – Syed
    Commented Feb 28, 2022 at 11:37
  • $\begingroup$ @Syed what do you mean? $\endgroup$
    – hana
    Commented Feb 28, 2022 at 11:57

2 Answers 2

3
$\begingroup$

This is a bug and is fixed in v13.1 to give the following correct results.

BodePlot[-(1/(s + 1000)), PlotLayout -> "Phase", "PhaseRange" -> #, 
   PlotLabel -> Switch[#, Automatic, #, _, Row[{#, " i.e. ", N[#/Degree]}]] ] & /@ 
      {Automatic, {-π, π}, {0, 2 π}, {2 π, 4 π}}

enter image description here

$\endgroup$
3
$\begingroup$

Everything is working correctly. Mathematica is showing a correct Bode plot, the frequency range is just automatically set to display interesting (attenuating, likely to contain gain & phase margins) part.

First of all, for your filter, the minus sign reverses the phase ($-\pi$) and shifts backwards. So the range of phase shift starts from $-\pi$ until, as this is a decay transfer, $-\pi-\pi/2$. The interesting part happens at about $1000\;\mathrm{Hz}$, at its decay rate, as shown in your plot. To have wider frequency range,

BodePlot[TransferFunctionModel[-1/(s + 1000), s], {10^-1, 10^8}, PlotLayout -> "Phase", PhaseRange -> {0, 2 Pi}]

enter image description here

$\endgroup$
31
  • 1
    $\begingroup$ Let's say it is required to show this plot from -180 to -225 degrees., How could it be done? $\endgroup$
    – Syed
    Commented Feb 28, 2022 at 23:02
  • 1
    $\begingroup$ Your TF starts at -180 due to a negative sign and loses another 90 for the only pole encountered. In Mathematica, try: Mod[#, 360] & /@ {-180, -270}. This is what you are seeing. This is similar to Matlab's unwrap. $\endgroup$
    – Syed
    Commented Mar 2, 2022 at 14:02
  • 1
    $\begingroup$ I think you have to keep adding/subtracting $2\pi$ till it is in the range $0$-$2\pi$. While specifying PhaseRange it has to be a multiple of $2\pi$ between min and max values, so that leaves us with $4\pi$ for the max value. $\endgroup$
    – Syed
    Commented Mar 2, 2022 at 17:16
  • 1
    $\begingroup$ @hana Your question did not ask that, but that the Bode plot is simply 'not work'. And through your comments I came to realize that your understanding on the subject matter is simply insufficient, which is the root of your question. Then kindly updated the answer explaining what PhaseRange means and why the $y$-axis ranges from $-180^\circ$ to $-270^\circ$, which you still fail to grasp. $\endgroup$
    – Shin Kim
    Commented Mar 2, 2022 at 17:36
  • 1
    $\begingroup$ @I asked in the comment and Syed finally explained it. Your answer mentioned nothing about that. $\endgroup$
    – hana
    Commented Mar 2, 2022 at 17:38

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.