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.

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

  • 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) – Betelgeuse Oct 12 at 9:15
  • 1
    @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. – kglr Oct 12 at 9:23
  • Indeed, I don't see any other options.. – Betelgeuse Oct 12 at 9:44
  • @Betelgeuse are you aware that dB are logarithmic? – Gladaed Oct 12 at 10:32
  • @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. – Betelgeuse Oct 12 at 11:03

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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