Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I use Mathematica to draw a bode plot, it always gives the precise version, like this:

BodePlot[(10 (s + 3))/(s (s + 2) (s^2 + s + 2))]

enter image description here

How can I draw the asymptotic version, the kind where 1/(1 + jw) is represented as a -20dB straight line but not a curve?

share|improve this question
    
Could you provide an example? –  partial81 Jun 24 '13 at 11:53

1 Answer 1

up vote 7 down vote accepted

We can draw the asymptotes using Epilog. The frequencies of interest are the max and min values and the corner frequencies.

tfm = (10 (3 + s))/(s (2 + s) (2 + s + s^2));
minF = Log10[0.001];
maxF = Log10[100];
cF1 = Log10[Sqrt[2]];
cF2 = Log10[2];
cF3 = Log10[3];
xcoords = {minF, cF1, cF2, cF3, maxF};

The magnitude at the lowest frequency.

mag0 = 20 Log10@Abs[tfm /. s -> I 0.001];

The magnitudes computed at the other frequencies of interest based on the slopes of the asymptotes. For example, between $minF$ and $cF1$ the slope is -20 db/decade.

ls = {mag0, -20 (cF1 - minF), -60 (cF2 - cF1), -80 (cF3 - 
  cF2), -60 (maxF - cF3)};
ycoords = FoldList[Plus, ls[[1]], ls[[2 ;; -1]]];

Finally render the plot.

BodePlot[tfm, Epilog -> {{Dashed, Line[Thread[{xcoords, ycoords}]]}, {}}][[1, 1, 1]]

enter image description here

The same process repeated for 10/(s+1).

tfm = 10/(s + 1);
minF = Log10[0.001];
maxF = Log10[100];
cF1 = Log10[1];
xcoords = {minF, cF1, maxF};
mag0 = 20 Log10@Abs[tfm /. s -> I 0.001];
ls = {mag0, 0, -20 (maxF - cF1)};
ycoords = FoldList[Plus, ls[[1]], ls[[2 ;; -1]]];
BodePlot[tfm, Epilog -> {{Dashed, Line[Thread[{xcoords, ycoords}]]}, {}}][[1,1,1]]

enter image description here

share|improve this answer
    
Thank you very much! maybe I could try to convert this to a more general function. Matlab's already got bode_as() by Valerio Scordamaglia, though. But Mathematica's results look much better. –  Lewen Jun 25 '13 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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