To plot transfer functions in Matlab, you first need to define the transfer function model using the built-in tf()
function. The tf()
function takes in two input arguments, the numerator and denominator of the transfer function in descending powers of s
.
For example, let's say we want to define a transfer function with a numerator of 1
and a denominator of s^2 + 2s + 1
. We can do this by defining a variable G
as follows:
main.m42 chars4 lines
Once we have defined the transfer function model, we can plot it using the bode()
or nyquist()
functions, depending on the type of plot we want.
For a Bode plot, we can use the bode()
function as follows:
main.m9 chars2 lines
This will generate a plot of the magnitude and phase of the transfer function as a function of frequency.
For a Nyquist plot, we can use the nyquist()
function as follows:
main.m12 chars2 lines
This will generate a plot of the magnitude and phase of the transfer function as a function of frequency, but in a different format than the Bode plot.
Both the bode()
and nyquist()
functions have many options for customizing the plot, such as plotting multiple transfer functions on the same plot or changing the plot style. Refer to the Matlab documentation for more details.
gistlibby LogSnag