How MATLAB plots Bode plot of a given transfer function?

Given a transfer function $G(s)$ we can use bode(G) function in MATLAB to plot a Bode plot, i.e. the magnitudes and phases of $G(s)$ over a range of frequencies.

From mathematical point of view, we can calculate the magnitude and the phase of $G(s)$ only at a fixed frequency. So plotting all the magnitudes and phases over any range of frequencies is impossible, because there will be infinite amount of frequencies.

I guess MATLAB only computes few points inside the range of frequencies and connects these points using continuous function (because the magnitude and phase functions are continuous functions of frequency?).

But then there are two questions: How precise is that plot? OR how many points do we need to accurately estimate the plot?


Solution 1:

If you use the the function as '$bode(s)$', the frequency range and number of points are chosen automatically by Matlab.

Otherwise, if you use the the function as '$bode(s,w)$', then the frequency range and number of points are specified by the vector '$w$' which is provided by you. In this way, you have full control of the frequency range and precision of the plot, to the extent as precise as you like.