2
$\begingroup$

I have to plot a BodePlot with magnitude in db or log, but i could not find the option for setting the magnitude scale.

BodePlot[
    mytf,
    GridLines -> Automatic,
    PlotLabel -> {"Magnitude Plot", "Phase Plot"},
    MagnitudeDisplay -> Absolute
    ]

But apparently MagnitudeDisplay -> AbsoluteValues / Decibels is not an option for bodeplot. i tried also the option ScalingFunctions->{{magfreqscale,magscale},{phasefreqscale,phasescale}} setting ScalingFunctions -> {{"Log10", "Log10"}, {"Log10", "Degree"}} but again, the command is not valid.

$\endgroup$
3
$\begingroup$

You can use the option ScalingFunctions:

BodePlot >> Details and Options: enter image description here

BodePlot[TransferFunctionModel[{{{20}}, 20 + s}, s], 
  GridLines -> Automatic, 
  PlotLabel -> {"Magnitude Plot", "Phase Plot"}, 
  ScalingFunctions -> {{Automatic, "Absolute"}, {Automatic, "Radian"}}]

enter image description here

$\endgroup$
  • $\begingroup$ but in this case, the magnitude scale is linear in the y-axis. I would like to have a log-log plot instead. (log scale not only in the x-axis) $\endgroup$ – Betelgeuse Oct 12 '18 at 9:15
  • 1
    $\begingroup$ @Betelgeuse, the only options for the vertical scale are "dB" and "Absolute"; so I think the only way to get what you want is post-processing the output to rescale the vertical coordinates of lines. $\endgroup$ – kglr Oct 12 '18 at 9:23
  • $\begingroup$ Indeed, I don't see any other options.. $\endgroup$ – Betelgeuse Oct 12 '18 at 9:44
  • $\begingroup$ @Betelgeuse are you aware that dB are logarithmic? $\endgroup$ – Gladaed Oct 12 '18 at 10:32
  • $\begingroup$ @Gladaed, yes, I'm preparing some materials for students and their textbook displays the bode plot in log scale. I just wanted to show them both to let them understand. $\endgroup$ – Betelgeuse Oct 12 '18 at 11:03
1
$\begingroup$

Probably this is what you are looking for. It is a bit of a hack, and I think what you want should be an accepted value for ScalingFunctions.

bp = BodePlot[100/(s + 1)];
ft = FrameTicks /. 
     Cases[bp[[1, 1, 1]], HoldPattern[Rule][FrameTicks, x_], Infinity];
ft[[1, 1]] = ft[[1, 1]] /. {t_, v_} :> {t, v/20.};
bp[[1, 1, 1]] = Show[bp[[1, 1, 1]], FrameTicks -> ft];
bp

enter image description here

$\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.