nyquist plot in matlab

To plot the Nyquist plot in MATLAB for a given transfer function G(s), we can use the nyquist command. Here's some sample code:

main.m
num = [1];
den = [1, 2, 1];
G = tf(num, den);
nyquist(G);
58 chars
5 lines

In this code, we first define the numerator and denominator of the transfer function as num and den, respectively. We then create the transfer function G using the tf command. Finally, we plot the Nyquist plot of G using the nyquist command.

We can also customize the Nyquist plot by specifying the frequency range using the omega input argument, and changing the plot formatting. Here's an example:

main.m
num = [1];
den = [1, 2, 1];
G = tf(num, den);
opts = bodeoptions;
opts.FreqUnits = 'Hz';
opts.PhaseVisible = 'off';
nyquist(G,logspace(-2,4,1000),opts)
152 chars
8 lines

In this code, we use the bodeoptions command to customize the plot formatting. We set the frequency units to Hz and turn off the phase plot. We also specify a frequency range of logspace(-2,4,1000), which is logarithmically spaced between 0.01 and 10,000.

gistlibby LogSnag