How to draw a Bode plot? Well, the answer seams easy. If you have a MATLAB distribution with Control System Toolbox, you can do this using just a single command, for example,
1
|
|
Indeed, MATLAB integrates so many powerful tools that make scientists and engineers’ lives easier. However, this is not the end of our story. Yes, the figure created in MATLAB looks really, really ugly. If you want a publishable quality figure, which includes more colors, more line styles, more elegant annotations and even more, the mathematical equations, you will feel utterly disappointed in the MATLAB’s plotting ability.
So what is the solution?
- R + Sweave/pgfSweave? Unfortunately, as far as I know, R (and its official package repository) does not provide a bode-plot relevant function. (If anyone knows such a function (or better, a control system package), please leave your comment here. Thanks.)
- Python + Numpy/Scipy + matplotlib? Yer, this looks like a happy combination. However, you have to learn Python, and, of course, Numpy/Scipy/matplotlib.
- MATLAB + matlab2pgfplots/matlab2tikz? A clumsy method, and even worse, it does now work for the figure create by
bode()
function. (In MATLAB 2009b or earlier, the objects generated by the functionbode()
is quite different from ones generated by the standard plotting commandplot()
. So you won’t get what you want, if you simply use matlab2pgfplots/matlab2tikz to convert MATLAB figure to PGF/TikZ file. Of course, there are some tricks to do it.) - Octave + gnuplot + epslatex/pslatex? OK, it could do the job. But how to put an equation in the upper subfigure (magnitude)? Again need some tricks and more complicate.
- gnuplot + tikz terminal? This is a solution that satisfies everything. But do you really want to switch between gnuplot and tex all the time when you revise your work? Unless you are an emacs/Vim user, you will find this process is pretty annoying.
- Can we do everything in TeX?
The answer is yes. Thank Papanicola Robert for his excellent work, the LaTeX package, bodegraph (PGF/TikZ based). Now using a single toolset, in a single editing environment, do a beautiful job. The below is the tex file which draws the bode plots for two control systems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
Here is he thumbnail of the plot. You can find the tex and pdf file from my SkyDrive.
Update:
The code has been included in the PGF/TikZ gallery, TeXample.net, see here.