Interactively create linear analysis response plots in the Live Editor
The Create Plot Live Editor task lets you interactively create time-domain and frequency-domain analysis plots for dynamic system models in your MATLAB® workspace. This page describes a subset of the functionality available in the Create Plot live task — the subset available when you select Control System Plots in the Category menu. For more information about the task in general, see the Create Plot Live Editor task reference page.
Open the Create Plot
To add the Create Plot task to a live script in the MATLAB Live Editor:
On the Live Editor tab, click Task and select the Create Plot icon .
In a code block in the live script, type a relevant keyword, such as such as
impulse. Select Create Plot from the suggested command completions. When you add the task using this method, then MATLAB automatically selects the corresponding chart type in the Select visualization section of the task.
Interactively Create Bode Plot in the Live Editor
Use the Create Plot task in the Live Editor to interactively create and visualize different linear analysis plots. You can also use an options object from your MATLAB® workspace to customize your plot. Open this example to see a preconfigured script containing the Create Plot task to create a Bode plot.
For this example, consider the following SISO state-space model:
Create the SISO state-space model defined by the following state-space matrices:
A = [-1.5,-2;1,0]; B = [0.5;0]; C = [0,1]; D = 0; sys = ss(A,B,C,D);
To create a Bode plot of
sys, open the Create Plot task in the Live Editor. On the Live Editor tab, select Task > Create Plot. In the task, select
Controls Toolbox Plots from the Filter by Category dropdown menu. You can also directly search for the plot type by typing in the plot name in the Select visualization field.
Next, select bodeplot from the available plots. If you do not have a supported model type in your MATLAB workspace, then the respective plot type will not be available.
Use the Dynamic System dropdown menu to pick the appropriate model from your MATLAB workspace. You can use the Frequencies dropdown menu to specify a vector of frequencies. You can also customize your plot by using a predefined options object. For more information, see
For this example, pick
sys and leave the other options as
You can also select the color, line style and marker symbol for the plot using the Select optional visualization parameters menu. You can click to add more visualization parameters. For this example, change the line color to green.
To see the code that this task generates, expand the task display by clicking at the bottom of the task parameter area.
You can also overlay mutliple visualizations on the same plot axis. For more information and examples, see the Create Plot task reference page.
Dynamic System — Model to create the linear analysis response plot
dynamic system model | model array
Choose the dynamic system model or model array to create the linear analysis response plot. Dynamic systems that you can use include:
For tunable control design blocks, the task evaluates the model at its current value to plot the response data.
For uncertain control design blocks, the task plots the nominal value and random samples of the model.
Frequency-response data models such as
frdmodels to plot the Bode, sigma, Nyquist or Nichols response. For such models, the task plots the response at frequencies defined in the model.
Identified LTI models, such as
idtf(System Identification Toolbox),
idss(System Identification Toolbox), or
idproc(System Identification Toolbox) models. (Using identified models requires System Identification Toolbox™ software.)
You can only use a single model to plot Hankel singular values. For all other response plots, the task plots the responses of all models in the array on the same axes when you have an array of dynamic system models.
Plot Options — Plot options set for customization
BodeOptions object |
SigmaOptions object |
NicholsOptions object |
NyquistOptions object |
TimeOptions object |
PZOptions object |
Create and choose the correct options set based on the plot type as follows:
|Plot Type||Options Object||Creation Function|
Introduced in R2022b