主要内容

Impulseplot

Plot impulse response with additional plot customization options

描述

Impulseplotlets you plot dynamic system impulse responses with a broader range of plot customization options thanimpulse。You can useImpulseplotto obtain the plot handle and use it to customize the plot, such as modify the axes labels, limits and units. You can also useImpulseplotto draw an impulse response plot on an existing set of axes represented by an axes handle. To customize an existing impulse plot using the plot handle:

  1. Obtain the plot handle

  2. Usegetoptionsto obtain the option set

  3. 更新图使用setoptionsto modify the required options

有关更多信息,请参阅Customizing Response Plots from the Command Line(控制系统工具箱)。To create impulse plots with default options or to extract impulse response data, useimpulse

example

h= impulseplot(系统)绘制了脉冲响应的dynamic system model系统and returns the plot handleh到情节。您可以使用此手柄hto customize the plot with thegetoptionsandsetoptionscommands.

example

h= impulseplot(系统1,系统2,...,,,系统N)绘制多个动态系统的脉冲响应sys1,sys2,…,sysnon the same plot. All systems must have the same number of inputs and outputs to use this syntax.

example

h= impulseplot(系统1,LinesPec1,...,系统N,LinesPecN)sets the line style, marker type, and color for the impulse response of each system. All systems must have the same number of inputs and outputs to use this syntax.

example

h= impulseplot(___,tFinal)simulates the impulse response fromt = 0to the final timet = tFinal。SpecifytFinalin the system time units, specified in theTimeUnitproperty of系统。For discrete-time systems with unspecified sample time(Ts = -1),ImpulseplotinterpretstFinalas the number of sampling intervals to simulate.

example

h= impulseplot(___,t)simulates the impulse response using the time vectort。Specifytin the system time units, specified in theTimeUnitproperty of系统

h= impulseplot(AX,___)将冲动响应绘制在当前图中的对象带有句柄AX

example

h= impulseplot(___,情节)plots the impulse response with the options set specified in情节。You can use these options to customize the impulse plot appearance using the command line. Settings you specify in情节覆盖MATLAB中的首选项设置®session in which you runImpulseplot。Therefore, this syntax is useful when you want to write a script to generate multiple plots that look the same regardless of the local preferences.

例子

collapse all

For this example, use the plot handle to change the time units to minutes and turn on the grid.

Generate a random state-space model with 5 states and create the impulse response plot with plot handleh

rng(“默认”) sys = rss(5); h = impulseplot(sys);

图包含一个轴对象。轴对象包含一个类型行的对象。该对象代表系统。

Change the time units to minutes and turn on the grid. To do so, edit properties of the plot handle,husingsetoptions

setoptions(h,'TimeUnits','minutes','网格','on');

图包含一个轴对象。轴对象包含一个类型行的对象。该对象代表系统。

脉冲图会在您打电话时自动更新setoptions

Alternatively, you can also use the时波命令指定所需的绘图选项。首先,根据工具箱首选项创建一个选项集。

情节= timeoptions('cstprefs');

Change properties of the options set by setting the time units to minutes and enabling the grid.

情节。TimeUnits ='minutes'; plotoptions.Grid ='on'; impulseplot(sys,plotoptions);

图包含一个轴对象。轴对象包含一个类型行的对象。该对象代表系统。

您可以使用相同的选项集来创建具有相同自定义的多个脉冲图。根据您自己的工具箱首选项,您获得的情节可能与此图不同。在此示例中,仅您明确设置的属性TimeUnitsand网格, override the toolbox preferences.

For this example, consider a MIMO state-space model with 3 inputs, 3 outputs and 3 states. Create a impulse plot with red colored grid lines.

Create the MIMO state-space modelsys_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)
具有3个输出,3个输入和3个状态的状态空间模型。

用绘图手柄创建冲动图h并使用getoptions有关可用选项的列表。

h = ImpulSeplot(sys_mimo)

Figure contains 9 axes objects. Axes object 1 with title From: In(1) contains an object of type line. This object represents sys\_mimo. Axes object 2 contains an object of type line. This object represents sys\_mimo. Axes object 3 contains an object of type line. This object represents sys\_mimo. Axes object 4 with title From: In(2) contains an object of type line. This object represents sys\_mimo. Axes object 5 contains an object of type line. This object represents sys\_mimo. Axes object 6 contains an object of type line. This object represents sys\_mimo. Axes object 7 with title From: In(3) contains an object of type line. This object represents sys\_mimo. Axes object 8 contains an object of type line. This object represents sys\_mimo. Axes object 9 contains an object of type line. This object represents sys\_mimo.

h = resppack.timeplot
p = getOptions(h)
p = Normalize: 'off' SettleTimeThreshold: 0.0200 RiseTimeLimits: [0.1000 0.9000] TimeUnits: 'seconds' ConfidenceRegionNumberSD: 1 IOGrouping: 'none' InputLabels: [1x1 struct] OutputLabels: [1x1 struct] InputVisible: {3x1 cell} OutputVisible: {3x1 cell} Title: [1x1 struct] XLabel: [1x1 struct] YLabel: [1x1 struct] TickLabel: [1x1 struct] Grid: 'off' GridColor: [0.1500 0.1500 0.1500] XLim: {3x1 cell} YLim: {3x1 cell} XLimMode: {3x1 cell} YLimMode: {3x1 cell}

Usesetoptions使用所需的自定义更新图。

setoptions(h,'网格','on','GridColor',[1 0 0]);

Figure contains 9 axes objects. Axes object 1 with title From: In(1) contains an object of type line. This object represents sys\_mimo. Axes object 2 contains an object of type line. This object represents sys\_mimo. Axes object 3 contains an object of type line. This object represents sys\_mimo. Axes object 4 with title From: In(2) contains an object of type line. This object represents sys\_mimo. Axes object 5 contains an object of type line. This object represents sys\_mimo. Axes object 6 contains an object of type line. This object represents sys\_mimo. Axes object 7 with title From: In(3) contains an object of type line. This object represents sys\_mimo. Axes object 8 contains an object of type line. This object represents sys\_mimo. Axes object 9 contains an object of type line. This object represents sys\_mimo.

脉冲图会在您打电话时自动更新setoptions。For MIMO models,Impulseplotproduces a grid of plots, each plot displaying the impulse response of one I/O pair.

Compare the impulse response of a parametric identified model to a nonparametric (empirical) model, and view their 3-σ confidence regions. (Identified models require System Identification Toolbox™ software.)

Identify a parametric and a nonparametric model from sample data.

loadIDDATA1Z1sys1 = sest(z1,4);sys2 = impulseest(z1);

Plot the impulse responses of both identified models. Use the plot handle to display the 3-σ confidence regions.

t = -1:0.1:5;h = ImpulSeplot(sys1,'r',sys2,'b',t);showconconceidence(h,3)传奇('parametric','nonparametric')

图包含一个轴对象。带有标题的轴对象从:u1到:y1包含3个类型行的对象。这些对象代表参数,非参数。

非参数模型SYS2shows higher uncertainty.

在此示例中,检查以下零极细胞模型的脉冲响应,并将冲动图限制在tFinal= 15 s。为标题使用15点蓝色文本。无论其生成的MATLAB会话的偏好如何,该图应看起来相同。

系统= zpk(-1,[-0.2+3j,-0.2-3j],1)*tf([1 1],[1 0.05]); tFinal = 15;

First, create a default options set using时波

情节= timeoptions;

接下来更改选项集的必需属性情节

plotoptions.title.fontsize = 15;plotOptions.title.color = [0 0 1];

现在,使用选项集创建冲动响应图情节

h = ImpulSeplot(sys,tfinal,plotOptions);

图包含一个轴对象。轴对象包含一个类型行的对象。该对象代表系统。

Because情节从固定的选项开始,绘图结果独立于MATLAB会话的工具箱首选项。

Input Arguments

collapse all

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 astf(控制系统工具箱),ZPK(控制系统工具箱), orss(控制系统工具箱)models.

  • Sparse state-space models, such assparss(控制系统工具箱)ormechss(控制系统工具箱)models. Final timetFinal使用稀疏模型时必须指定。

  • Generalized or uncertain LTI models such asgenss(控制系统工具箱)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 impulse response data.

    • For uncertain control design blocks, the function plots the nominal value and random samples of the model.

  • Identified LTI models, such asidtf,idss, oridprocmodels.

If系统是模型的数组,该函数绘制了同一轴上阵列中所有模型的脉冲响应。

Line style, marker, and color, specified as a character vector or string 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.

例子:'--or'是带有圆形标记的红色虚线

Line Style 描述
- 实线
-- Dashed line
: Dotted line
-. Dash-dot line
Marker 描述
'o' Circle
'+' 加号
'*' Asterisk
'.' Point
'x'
'_' Horizontal line
'|' 垂线
's' Square
'd' Diamond
'^' Upward-pointing triangle
'v' Downward-pointing triangle
'>' Right-pointing triangle
'<' 左点三角形
'p' 五角星
'H' Hexagram
Color 描述

y

yellow

m

magenta

c

青色

r

red

g

绿色

b

blue

w

white

k

black

Final time for impulse response computation, specified as a scalar. SpecifytFinalin the system time units, specified in theTimeUnitproperty of系统。For discrete-time systems with unspecified sample time(Ts = -1),ImpulseplotinterpretstFinalas the number of sampling intervals to simulate.

脉冲响应模拟的时间,指定为向量。指定时间向量tin the system time units, specified in theTimeUnitproperty of系统。The time vector must be real, finite, and must contain monotonically increasing and evenly spaced time samples.

The time vectortis:

  • t = T最初的:tsample:tfinal,用于离散的时间系统。

  • t = T最初的:dt:Tfinal, for continuous-time systems. Here,dt是一个离散的样本时间近似的the continuous-time system.

目标轴, specified as an目的。如果您不指定轴和电流轴是笛卡尔轴,则Impulseplotplots on the current axes. UseAX在创建冲动图时将其绘制成特定的轴。

Impulse plot options set, specified as aTimePlotOptions目的。You can use this option set to customize the impulse plot appearance. Use时波to create the option set. Settings you specify in情节覆盖MATLAB中的首选项设置session in which you runImpulseplot。Therefore,情节is useful when you want to write a script to generate multiple plots that look the same regardless of the local preferences.

For the list of available options, see时波

输出参数

collapse all

Plot handle, returned as ahandle目的。Use the handlehto get and set the properties of the impulse plot usinggetoptionsandsetoptions。有关可用选项的列表,请参阅Properties and Values Referencesection inCustomizing Response Plots from the Command Line(控制系统工具箱)

Version History

Introduced in R2012a