nyquistplot
Plot Nyquist response of dynamic system
Description
The nyquistplot
function plots the Nyquist response of a dynamic system
model and returns a
NyquistPlot
chart object. To customize the plot, modify the properties of
the chart object using dot notation. For more information, see Customize Linear Analysis Plots at Command Line.
To obtain Nyquist response data, use nyquist
.
Creation
Syntax
Description
plots
the Nyquist response of the dynamic system model np
= nyquistplot(sys
)sys
and returns
the corresponding chart object.
If sys
is a multi-input, multi-output (MIMO) model, then
bodeplot
produces a grid of Bode plots with each plot displaying the
frequency response of one input-output pair.
plots the Nyquist response with the plotting options specified in
np
= nyquistplot(___,plotoptions
)plotoptions
. Settings you specify in
plotoptions
override the plotting preferences for the current
MATLAB® session. This syntax is useful when you want to write a script to generate
multiple plots that look the same regardless of the local preferences.
plots the Nyquist response in the specified parent graphics container, such as a
np
= nyquistplot(parent
,___)Figure
or TiledChartLayout
, and sets the
Parent
property. Use this syntax when you want to create a plot
in a specified open figure or when creating apps in App Designer.
Input Arguments
sys
— Dynamic system
dynamic system model | model array
Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can use include:
Continuous-time or discrete-time numeric LTI models, such as
tf
,zpk
, orss
models.Generalized or uncertain LTI models such as
genss
oruss
(Robust Control Toolbox) models. Using uncertain models requires Robust Control Toolbox™ software.For tunable control design blocks, the function evaluates the model at its current value to plot the response.
For uncertain control design blocks, the function plots the nominal value and random samples of the model.
Identified LTI models, such as
idtf
(System Identification Toolbox),idss
(System Identification Toolbox), oridproc
(System Identification Toolbox) models. Using identified models requires System Identification Toolbox™ software.
If sys
is an array of models, the plot shows responses of all models in
the array on the same axes.
LineSpec
— Line style, marker, and color
string | character vector
Line style, marker, and color, specified as a string or character vector containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.
Example: '--or'
is a red dashed line with circle markers
Line Style | Description |
---|---|
"-" | Solid line |
"--" | Dashed line |
":" | Dotted line |
"-." | Dash-dotted line |
Marker | Description |
---|---|
"o" | Circle |
"+" | Plus sign |
"*" | Asterisk |
"." | Point |
"x" | Cross |
"_" | Horizontal line |
"|" | Vertical line |
"s" | Square |
"d" | Diamond |
"^" | Upward-pointing triangle |
"v" | Downward-pointing triangle |
">" | Right-pointing triangle |
"<" | Left-pointing triangle |
"p" | Pentagram |
"h" | Hexagram |
Color | Description |
---|---|
"r" | red |
"g" | green |
"b" | blue |
"c" | cyan |
"m" | magenta |
"y" | yellow |
"k" | black |
"w" | white |
w
— Frequencies
{wmin,wmax}
| vector | []
Frequencies at which to compute the response, specified as one of the following:
Cell array of the form
{wmin,wmax}
— Compute the response at frequencies in the range fromwmin
towmax
. Ifwmax
is greater than the Nyquist frequency ofsys
, the response is computed only up to the Nyquist frequency.Vector of frequencies — Compute the response at each specified frequency. For example, use
logspace
to generate a row vector with logarithmically spaced frequency values. The vectorw
can contain both positive and negative frequencies.[]
— Automatically select frequencies based on system dynamics.
Specify frequencies in units of rad/TimeUnit
, where
TimeUnit
is the TimeUnit
property of the
model.
plotoptions
— Nyquist plot options
nyquistoptions
object
Nyquist plot options, specified as a nyquistoptions
object. You can use these options to
customize the Nyquist plot appearance. Settings you specify in
plotoptions
override the preference settings for the current
MATLAB session.
parent
— Parent container
Figure
object (default) | TiledChartLayout
object | UIFigure
object | UIGridLayout
object | UIPanel
object | UITab
object
Parent container of the chart, specified as one of the following objects:
Figure
TiledChartLayout
UIFigure
UIGridLayout
UIPanel
UITab
Properties
Note
The properties listed here are only a subset. For a complete list, see NyquistPlot Properties.
Responses
— Model responses
NyquistResponse
object | array of NyquistResponse
objects
Model responses, specified as a NyquistResponse
object or an array of such objects. Use this property to modify the dynamic system model or appearance for each response in the plot. Each NyquistResponse
object has the following fields.
SourceData
— Source data
structure
Source data for the response, specified as a structure with the following fields.
Model
— Dynamic system
dynamic system model | model array
Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models.
When you initially create a plot, Model
matches the value you specify for sys
.
FrequencySpec
— Frequencies
{wmin,wmax}
| vector | []
Frequencies at which to compute the response, specified as one of the following:
Cell array of the form
{wmin,wmax}
— Compute the response at frequencies in the range fromwmin
towmax
.Vector of frequencies — Compute the response at each specified frequency. For example, use
logspace
to generate a row vector with logarithmically spaced frequency values. The vectorw
can contain both positive and negative frequencies.[]
— Automatically select frequencies based on system dynamics.
Specify frequencies in units of rad/TimeUnit
, where TimeUnit
is the TimeUnit
property of the model.
When you initially create a plot:
FrequencySpec
matches the value you specify for thew
argument.If you do not specify
w
,FrequencySpec
is empty and frequencies are selected based on the system dynamics.
Name
— Response name
string | character vector
Response name, specified as a string or character vector and stored as a string.
Visible
— Response visibility
"on"
(default) | on/off logical value
Response visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the response in the plot."off"
,0
, orfalse
— Do not display the response in the plot.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
LegendDisplay
— Option to list response in legend
"on"
(default) | on/off logical value
Option to list response in legend, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— List the response in the legend."off"
,0
, orfalse
— Do not list the response in the legend.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
MarkerStyle
— Marker style
"none"
| "o"
| "+"
| "*"
| "."
| ...
Marker style, specified as one of the following values.
Marker | Description |
---|---|
"none" | No marker |
"o" | Circle |
"+" | Plus sign |
"*" | Asterisk |
"." | Point |
"x" | Cross |
"_" | Horizontal line |
"|" | Vertical line |
"s" | Square |
"d" | Diamond |
"^" | Upward-pointing triangle |
"v" | Downward-pointing triangle |
">" | Right-pointing triangle |
"<" | Left-pointing triangle |
"p" | Pentagram |
"h" | Hexagram |
Color
— Plot color
RGB triplet | hexadecimal color code | color name
Plot color, specified as an RGB triplet or a hexadecimal color code and stored as an RGB triplet.
Alternatively, you can specify some common colors by name. The following table lists these colors and their corresponding RGB triplets and hexadecimal color codes.
Color Name | RGB Triplet | Hexadecimal Color Code |
---|---|---|
| [1 0 0] | #FF0000 |
| [0 1 0] | #00FF00 |
| [0 0 1] | #0000FF |
| [0 1 1] | #00FFFF |
| [1 0 1] | #FF00FF |
| [1 1 0] | #FFFF00 |
| [0 0 0] | #000000 |
| [1 1 1] | #FFFFFF |
LineStyle
— Line style
"-"
| "--"
| ":"
| "-."
Line style, specified as one of the following values.
Line Style | Description |
---|---|
"-" | Solid line |
"--" | Dashed line |
":" | Dotted line |
"-." | Dash-dotted line |
MarkerSize
— Marker size
positive scalar
Marker size, specified as a positive scalar.
LineWidth
— Line width
positive scalar
Line width, specified as a positive scalar.
Characteristics
— Response characteristics
CharacteristicsManager
object
Response characteristics to display in the plot, specified as a
CharacteristicsManager
object with the following properties.
FrequencyPeakResponse
— Visibility of peak response
CharacteristicOption
object
Visibility of peak response in magnitude plot, specified as a
CharacteristicOption
object with the following
property.
Visible
— Peak response visibility
"off"
(default) | on/off logical value
Peak response visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the peak response."off"
,0
, orfalse
— Do not display the peak response.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
AllStabilityMargins
— Visibility of all stability margins
CharacteristicOption
object
Visibility of all stability margins, specified as a CharacteristicOption
object with the following property.
Visible
— Margin visibility
"off"
(default) | on/off logical value
Margin visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the margins."off"
,0
, orfalse
— Do not display the margins.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
MinimumStabilityMargins
— Visibility of minimum stability margins
CharacteristicOption
object
Visibility of minimum stability margins, specified as a CharacteristicOption
object with the following property.
Visible
— Margin visibility
"off"
(default) | on/off logical value
Margin visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the margins."off"
,0
, orfalse
— Do not display the margins.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
ConfidenceRegion
— Confidence region
CharacteristicOption
object
Confidence region for identified models, specified as a
CharacteristicOption
object with the following
properties.
Visible
— Confidence region visibility
"off"
(default) | on/off logical value
Confidence region visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the confidence region."off"
,0
, orfalse
— Do not display the confidence region.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
DisplaySampling
— Frequency spacing of confidence ellipses
5
(default) | positive integer
Frequency spacing of confidence ellipses used to plot the
confidence region, specified as a positive integer. For example,
when DisplaySampling
is
5
the confidence ellipses are shown at
every fifth frequency sample.
NumberOfStandardDeviations
— Number of standard deviations
1
(default) | positive scalar
Number of standard deviations to display for the confidence region, specified as a positive scalar.
Dependencies
ConfidenceRegion
is supported only for identified
models, which require System Identification Toolbox software.
ShowNegativeFrequencies
— Option to show response for negative frequencies
"on"
(default) | on/off logical value
Option to show response for negative frequencies, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the response for negative frequencies."off"
,0
, orfalse
— Do not display the response for negative frequencies.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
FrequencyUnit
— Frequency units
"rad/s"
| "Hz"
| "rpm"
| ...
Frequency units, specified as one of the following values:
"Hz"
"rad/s"
"rpm"
"kHz"
"MHz"
"GHz"
"rad/nanosecond"
"rad/microsecond"
"rad/millisecond"
"rad/minute"
"rad/hour"
"rad/day"
"rad/week"
"rad/month"
"rad/year"
"cycles/nanosecond"
"cycles/microsecond"
"cycles/millisecond"
"cycles/hour"
"cycles/day"
"cycles/week"
"cycles/month"
"cycles/year"
Dependencies
By default, the response uses the frequency units of the plotted linear system. You can override the default units by specifying toolbox preferences. For more information, see Specify Toolbox Preferences for Linear Analysis Plots.
MagnitudeUnit
— Magnitude units
"dB"
| "abs"
Magnitude units, specified as one of the following:
"dB"
— Decibels"abs"
— Absolute value
Dependencies
The default magnitude units depend on the toolbox preferences. For more information, see Specify Toolbox Preferences for Linear Analysis Plots.
PhaseUnit
— Phase units
"deg"
| "rad"
Phase units, specified as one of the following:
"deg"
— Degrees"rad"
— Radians
Dependencies
The default phase units depend on the toolbox preferences. For more information, see Specify Toolbox Preferences for Linear Analysis Plots.
Visible
— Chart visibility
"on"
(default) | on/off logical value
Chart visibility, specified as one of the following logical on/off values:
"on"
,1
, ortrue
— Display the chart."off"
,0
, orfalse
— Hide the chart without deleting it. You still can access the properties of chart when it is not visible.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
IOGrouping
— Grouping of inputs and outputs pairs
"none"
(default) | "inputs"
| "outputs"
| "all"
Grouping of inputs and outputs pairs, specified as one of the following:
"none"
— Do not group inputs or outputs."inputs"
— Group only inputs."outputs"
— Group only outputs."all"
— Group all input-output pairs.
InputVisible
— Option to display inputs
on/off logical value | array of on/off logical values
Option to display inputs, specified as one of the following logical on/off values or an array of such values:
"on"
,1
, ortrue
— Display the corresponding input."off"
,0
, orfalse
— Hide the corresponding input.
InputVisible
is an array when the plotted system has multiple inputs. By
default, all inputs are visible in the plot.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
or an array of such values.
OutputVisible
— Option to display outputs
on/off logical value | array of on/off logical values
Option to display outputs, specified as one of the following logical on/off values or an array of such values:
"on"
,1
, ortrue
— Display the corresponding output."off"
,0
, orfalse
— Hide the corresponding output.
OutputVisible
is an array when the plotted system has multiple outputs.
By default, all outputs are visible in the plot.
The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
or an array of such values.
Object Functions
addResponse | Add dynamic system response to existing response plot |
showConfidence (System Identification Toolbox) | Display confidence regions on response plots for identified models |
zoomcp | Zoom Nyquist plot to region around critical point |
Examples
Customize Nyquist Plot
For this example, use the plot handle to change the phase units to radians and to turn the grid on.
Generate a random state-space model with 5 states and create the Nyquist diagram with chart object np
.
rng("default")
sys = rss(5);
np = nyquistplot(sys);
Change the phase units to radians and turn on the grid. To do so, edit properties of the chart object.
np.PhaseUnit = "rad"; grid on;
The Nyquist plot automatically updates when you modify the chart object.
Alternatively, you can also use the nyquistoptions
command to specify the required plot options. First, create an options set based on the toolbox preferences.
plotoptions = nyquistoptions("cstprefs");
Change properties of the options set by setting the phase units to radians and enabling the grid.
plotoptions.PhaseUnits = "rad"; plotoptions.Grid = "on"; nyquistplot(sys,plotoptions);
Depending on your own toolbox preferences, the plot you obtain might look different from this plot. Only the properties that you set explicitly, in this example PhaseUnits
and Grid
, override the toolbox preferences.
Customize Nyquist Plot Title
Create a Nyquist plot of a dynamic system model and create the corresponding chart object.
sys = tf(100,[1,2,1]); np = nyquistplot(sys);
Change the text of the plot title..
np.Title.String = "Nyquist Plot of sys";
Zoom on Critical Point
Plot the Nyquist frequency response of a dynamic system. Assign a variable name to the plot handle so that you can access it for further manipulation.
sys = tf(100,[1,2,1]); h = nyquistplot(sys);
Zoom in on the critical point, (–1,0). You can do so interactively by right-clicking on the plot and selecting Zoom on (-1,0). Alternatively, use the zoomcp
command on the plot handle h
.
zoomcp(h)
Nyquist Plot of Identified Models with Confidence Regions at Selected Points
Compare the frequency responses of identified state-space models of order 2 and 6 along with their 1-std
confidence regions rendered at every 50th frequency sample.
Load the identified model data and estimate the state-space models using n4sid
. Then, plot the Nyquist diagram.
load iddata1
sys1 = n4sid(z1,2);
sys2 = n4sid(z1,6);
w = linspace(10,10*pi,256);
np = nyquistplot(sys1,sys2,w);
Both models produce about 76% fit to data. However, sys2
shows higher uncertainty in its frequency response, especially close to Nyquist frequency as shown by the plot. To see this, show the confidence region at a subset of the points at which the Nyquist response is displayed.
np.ShowNegativeFrequencies = "off"; np.Characteristics.ConfidenceRegion.DisplaySampling = 50; np.Characteristics.ConfidenceRegion.Visible = "on";
Alternatively, to turn on the confidence region display, right-click the plot and select Characteristics > Confidence Region.
Nyquist Plot with Specific Customization
For this example, consider a MIMO state-space model with 3 inputs, 3 outputs and 3 states. Create a Nyquist plot, display only the partial contour.
Create the MIMO state-space model sys_mimo
.
J = [8 -3 -3; -3 8 -3; -3 -3 8]; F = 0.2*eye(3); A = -J\F; B = inv(J); C = eye(3); D = 0; sys_mimo = ss(A,B,C,D); size(sys_mimo)
State-space model with 3 outputs, 3 inputs, and 3 states.
Create a Nyquist plot with chart object np
.
np = nyquistplot(sys_mimo);
Suppress the negative frequency data from the plot.
np.ShowNegativeFrequencies = "off";
The Nyquist plot automatically updates when you modify the chart object. For MIMO models, nyquistplot
produces an array of Nyquist diagrams, each plot displaying the frequency response of one I/O pair.
Tips
There are two zoom options available from the right-click menu that apply specifically to Nyquist plots:
Full View — Clips unbounded branches of the Nyquist plot, but still includes the critical point (–1, 0).
Zoom on (-1,0) — Zooms around the critical point (–1,0). To access critical-point zoom programmatically, use the
zoomcp
command
Version History
Introduced before R2006aR2024b: Improved customization workflows and integration with MATLAB plotting tools
Starting in R2024b, nyquistplot
returns a NyquistPlot
chart object. Previously, the nyquistplot
function returned a handle to the
resulting plot.
The new chart object allows you to customize your plot using dot notation.
The new chart object also improves integration with MATLAB plotting tools. For example:
You can now add Nyquist plots to tiled chart layouts.
Saving and loading a parent figure now maintains full plot interactivity.
You can add a response your Nyquist plot using the new
addResponse
function.
The following functionality changes might require updates to your code.
The
gca
function now returns the chart object rather than an axes within the plot.You can no longer access the graphics objects within a Nyquist plot using the
Children
property of its parent figure.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)