Hi!
I am trying to extract the data points from a BodePlot. For example:
bpx = BodePlot[
TransferFunctionModel[{{{20}}, 20 + s}, s]]
This plots the Bode of the transfer funtion. I tried the following:
points = Cases[Normal@bpx, Line[pts_] -> pts, Infinity]
which, returns a table with the points for x and y coordinates. For the values of y-axis, it seems to be right. However, the command is not returning the correct values for x-axis.
Thanks!
Lucas
Hi Lucas,
The x axis is logarithmic, so to get the actual values:
points = Cases[bpx, Line[pts_] -> pts, Infinity] // MapAt[(10^# &), #, {All, All, 1}] &;
points //
Map[ListLogLinearPlot[#, ImageSize -> Medium, Joined -> True, PlotRange -> All] &] //
Row
Hi Rohit Namjoshi
Thank you very much for your reply!
dlkeith
(David Keith)
April 4, 2020, 4:33pm
4
It is also possible to define a function of w (meaning omega) to produce the values needed. For example, below the transfer function magnitude in dB is calculated:
tf = 20/(20 + s)
(* 20/(20+s) *)
tfw = tf /. s -> I w
(* 20/(20+\[ImaginaryI] w) *)
LogLinearPlot[20 Log10[Abs[tfw]], {w, 1, 1000}, Frame -> True,
GridLines -> Automatic
dBOut[w_] = 20 Log10[Abs[tfw]] // N;
outputTable = Table[{w, dBOut[w]}, {w, {1, 5, 10, 50, 100, 500}}]
(* {{1,-0.010843812922199395`},{5,-0.2632893872234916`},{10,-0.\
9691001300805643`},{50,-8.603380065709935`},{100,-14.149733479708177`}\
,{500,-27.965743332104292`}} *)