MATLAB Nichols Plot

From ControlTheoryPro.com

Jump to: navigation, search
Symbol.gif
MATLAB Nichols Plot
Green carrot left.gif
MATLAB Nyquist
Green carrot.jpg
In order to prevent spam, users must register before they can edit or create articles.


Contents

1 Introduction

This article is on the topic of creating Nichols plots in MATLAB. The quick answer is use the Nichols command. However, the Nichols command has several options and the plots generated by the nichols command are not easily reformatted. The default formatting of most MATLAB plots is good for analysis but less than ideal for dropping into Word and PowerPoint documents or even this website. As a result this article presents an alternative that requires more lines of code but offers the full formatting flexibility of the generic plot command.

2 MATLAB's Nichols Command

The basic Nichols command is as follows

 >> nichols(LTI_SYS)

where

The Nichols command will automatically call gcf which will put the Nichols plot on the current figure. If no figure exists then one is created by gcf.

If you wish to specify the frequency points at which LTI_SYS is plotted then create a frequency vector using logspace or linspace as follows

 >> freqVec = logspace(-1, 3, 5000);
 >> nichols(LTI_SYS, freqVec * (2*pi))

where

  • freqVec is a vector of 5000 frequencies, in Hz, spaced evenly on a log scale from 10-1 to 103
  • pi is a MATLAB constant equal to the value of LaTeX: \pi and in this case it is used to convert freqVec to rad/sec as it is passed to the Nichols command

2.1 Issues with the nichols command

The main issue with the nichols command is reformatting of the plot. The nichols command appears to use a normal semilogx plot and then apply patches or something similar to the figure. This can lead to odd behavior when attempting to create multi-line titles, reformat line widths or font sizes, etc. The normal relationship of axes to figure is just not quite present.

3 Manually create a Nichols plot

Since the bode command will return a magnitude and phase a nichols plot can be created manually. It is done in this fashion

 >> freqVec = logspace(-1, 3, 5000);
 >> [mag, phase] = bode(LTI_SYS, freqVec * (2*pi));
 >> figure;
 >> plot(phase(:), db(mag(:)))
 >> ngrid

Note that a Nichols plot is really only valid for an open loop transfer function.

4 See Also