# Program to make bode plot of transfer function?

For different purposes, I sometimes have to draw an bode plot. I first of would like to know if there is any piece of software which can draw them for me. So I gave in the transfer function and then it gives me the bode plot (both phase and the magnitude). This would save some time at occasions.

Ok, so now the real question. I have the following transfer function.

$$H(j\omega) = \frac{j \frac{\omega}{\omega_0} }{1 + 3j \frac{\omega}{\omega_0}}$$

The modulus can be calculated as follows (correct me if I am wrong):

$$|H(j\omega)| = 20 \log_{10}(p) - 20 \log_{10} \left(\sqrt{1+(3p)^2}\right)$$

(where $p=\frac{\omega}{\omega_0}$, with $\omega_0=\frac{1}{500 \times 6.37 \times 10^{-7}}$).

$20 \log_{10}(p)$, would be easy, but I am not sure how to calculate the second one? How do I calculate the (magnitude) bode plot of $-20 \log_{10} \left(\sqrt{1+(3p)^2} \right)$

• There are lots of options for Bode plotting. Matlab, Mathcad, Labview, hand coding in your favorite language, etc. I personally use Mathcad, but I use the old version, not the new "X" version as the graphing in the new version doesn't allow 2 y axes (to show gain and phase on the same plot.) You could even use Excel or the spreadsheet of your choice, but the equation display and presentation in Mathcad 15 are really nice. – John D Feb 4 '16 at 18:30

I will directly link to the Matlab bode plot section... http://www.mathworks.com/help/ident/ref/bode.html?refresh=true

It works nicely and the program is simple as dirt.

You probably don't have Matlab or other similar software, otherwise you would not be asking the question. So if you want a simple low-cost solution - use Excel. You'll also learn more about how the calculations are executed.

As for calculating the 2nd expression 'by hand', how far have you got? The calculation is pretty elementary.

I just use my favorite programming language (Rust) to output the results, either as an SVG image or as a text file that I then pipe into gnuplot.

Matlab is indeed very usefull for this, but also very expensive.

If you are familiar with linux I would advise to use Octave which is very similar to Matlab and it is free.

Another option is to use a web based solver, like WolframAlpha.

As the bode plot is used to give an impression of the transfer function and most of the time the exact value is not important, it is easier to sketch the plot than to calculate the phase and magnitude formula.

You already have the transfer function, so it is pretty easy to draw a bode plot on paper, by using some tricks. When you rewrite the formula to show the poles and zeroes, you can simply know where to draw them in the plot.

$$H(s) = \frac{s}{1 + 3s}$$ Zero: s=0

The zero gives a positive slope of 20db/dec.

Pole: (1+3s=0), so at s=-1/3

The pole gives a reduction of the slope at s=1/3, after which you get a horizontal line.

Only thing you need to know is the magnitude at a point in the graph. Easiest is to take the flat part (as it is still flat at infinity), so

$$H(s\rightarrow \infty) = \frac{1}{3}$$

For the phase plot, you start with the 90 degrees phase caused by the zero. As calculated, the pole causes a phase shift at s=1/3, so a transition is drawn centered at 1/3. As a rule of thumb, the transisition takes 2 decades (so from 0.03 to 3).

Look at this course for example to have some more info on drawing bode plots.