m一个in Content

ss

State-space model

desCription

Usessto create real-valued or complex-valued state-space models, or to convert动态系统模型到状态空间模型形式。您也可以使用ssto create generalized state-space (genss)模型或不确定状态空间(你ss(强大的控制工具箱)) 楷模。

状态空间模型是物理系统作为一组输入,输出和状态变量与一阶微分方程相关的数学表示。状态变量定义了输出变量的值。这ssmodel object can represent SISO or MIMO state-space models in continuous time or discrete time.

我nContinuous-time, a state-space model is of the following form:

X ˙ = 一个 X + b y = C X + d

这里,X,,,,yrepresent the states, inputs and outputs respectively, while一个,,,,b,,,,Cd是状态空间矩阵。这ssobject represents a state-space model in MATLAB®storing一个,,,,b,,,,Cd一个long with other information such as sample time, names and delays specific to the inputs and outputs.

您可以通过直接指定状态,输入和输出矩阵,或通过转换另一种类型的模型来创建状态空间模型对象(例如,传输函数模型tf)to state-space form. For more information, see州空间模型。您可以使用ss模型对象:

  • Perform linear analysis

  • Represent a linear time-invariant (LTI) model to perform control design

  • Combine with other LTI models to represent a more complex system

创建

desCription

例子

sys= ss(一个,,,,b,,,,C,,,,d创建以下形式的连续时间状态空间模型对象:

X ˙ = 一个 X + b y = C X + d

例如,考虑一种植物nxst一个tes,,,,纽约outputs, andnuinputs. The state-space matrices are:

  • 一个is annx-by-nxre一个l- or complex-valued matrix.

  • bis annx-by-nure一个l- or complex-valued matrix.

  • Cis an纽约-by-nxre一个l- or complex-valued matrix.

  • dis an纽约-by-nure一个l- or complex-valued matrix.

例子

sys= ss(一个,,,,b,,,,C,,,,d,,,,tsCre一个testHediscrete-time state-space model object of the following form with the sample timets(片刻之间):

X [[ n + 1 这是给予的 = 一个 X [[ n 这是给予的 + b [[ n 这是给予的 y [[ n 这是给予的 = C X [[ n 这是给予的 + d [[ n 这是给予的

To leave the sample time unspecified, settsto-1

例子

sys= ss(一个,,,,b,,,,C,,,,d,,,,ltiSys创建一个具有属性的状态空间模型,例如输入和输出名称,内部延迟以及从模型继承的样本时间值ltisys

例子

sys= ss(dCre一个tes一个st一个te-space model that represents the static gain,d。输出状态空间模型等效于ss(([[这是给予的,,,,[[这是给予的,,,,[[这是给予的,,,,d)

例子

sys= ss(___,,,,Name,Valuesetsproperties of the state-space model using one or moreName,Valuepair arguments for any of the previous input-argument combinations.

例子

sys= ss(ltiSysConverts the dynamic system modelltiSysto a state-space model. IfltiSys包含可调或不确定的元素,ss分别使用这些元素的当前或名义值。

例子

sys= ss(ltiSys,,,,零件Converts tossobject form the measured component, the noise component or both of specified零件of an identified linear time-invariant (LTI) modelltiSys。Use this syntax only whenltiSysis an identified (LTI) model such as anidtf((System Identification Toolbox),,,,IDSS((System Identification Toolbox),,,,IDPROC((System Identification Toolbox),,,,idpoly((System Identification Toolbox)or艾德格里((System Identification Toolbox)目的。

sys= ss(SSSYS,,,,“最小”)返回最小的状态空间实现,没有无法控制或无法观察的状态。这种认识等同于minreal(ss(sys))在哪里矩阵一个H一个stHesmallest possible dimension.

Conversion to state-space form is not uniquely defined in the SISO case. It is also not guaranteed to produce a minimal realization in the MIMO case. For more information, see推荐的工作表示

例子

sys= ss(SSSYS,,,,'explicit')ret你rns一个neXplicit state-space realization((e=我)of the dynamic system state-space modelSSSYSssret你rns一个nerror ifSSSYS是不适当的。有关明确状态空间实现的更多信息,请参见州空间模型

我nput Arguments

eXpand all

状态矩阵,指定为nx-by-nx矩阵在哪里,nxis the number of states. This input sets the value of property一个

我nput-to-state matrix, specified as annx-by-nu矩阵在哪里,nx是州的数量和nuis the number of inputs. This input sets the value of propertyb

状态到输出矩阵,指定为纽约-by-nx矩阵在哪里,nx是州的数量和纽约is the number of outputs. This input sets the value of propertyC

馈电矩阵,指定为纽约-by-nu矩阵在哪里,纽约is the number of outputs andnuis the number of inputs. This input sets the value of propertyd

样品时间,指定为标量。有关更多信息,请参阅TS财产。

动态系统转换为状态空间形式,,,,specified as a SISO or MIMOdyn一个mic system modelor array of dynamic system models. Dynamic systems that you can convert include:

  • Continuous-time or discrete-time numeric LTI models, such astf,,,,zpk,,,,ss,,,,orpid楷模。

  • Gener一个lized or uncertain LTI models such asgenssor你ss(强大的控制工具箱)楷模。(使用不确定的模型需要健壮的控制工具箱™软件。)

    最终的状态空间模型假设

    • C你rrentvalues of the tunable components for tunable control design blocks.

    • nominal model values for uncertain control design blocks.

  • 我dentified LTI models, such asidtf((System Identification Toolbox),,,,IDSS((System Identification Toolbox),,,,IDPROC((System Identification Toolbox),,,,idpoly((System Identification Toolbox),,,,和艾德格里((System Identification Toolbox)楷模。To select the component of the identified model to convert, specify零件。我f you do not specify零件,,,,ss默认情况下,将确定模型的测量组件转换为测量的组件。((Using identified models requires System Identification Toolbox™ software.)

Component of identified model to convert, specified as one of the following:

  • 'measured'-Convert the measured component ofsys

  • '噪音'-Convert the noise component ofsys

  • “增强”-Convert both the measured and noise components ofsys

零件only applies whensysis an identified LTI model.

有关已识别的LTI模型及其测量和噪声组件的更多信息,请参见确定的LTI模型

dyn一个mic system model to convert to minimal realization or explicit form, specified as anssmodel object.

Output Arguments

eXpand all

Output system model, returned as:

  • 一个st一个te-space (ss)model object, when the inputs一个,,,,b,,,,Cd是数字矩阵或从其他模型对象类型转换时。

  • 一个generalized state-space model (genss)object, when one or more of the matrices一个,,,,b,,,,Cdincludes tunable parameters, such asre一个lpparameters or generalized matrices (genmat)。For an example, seeCre一个teState-Space Model with Both Fixed and Tunable Parameters

  • 一个不确定的状态空间模型(你ss)object, when one or more of the inputs一个,,,,b,,,,Cdincludes uncertain matrices. Using uncertain models requires Robust Control Toolbox software.

Properties

eXpand all

状态矩阵,指定为nx-by-nx矩阵在哪里nxis the number of states. The state-matrix can be represented in many ways depending on the desired state-space model realization such as:

  • model Canonical Form

  • 伴侣规范形式

  • 可观察的规范形式

  • Controllable Canonical Form

有关更多信息,请参阅C一个nonical State-Space Realizations

我nput-to-state matrix, specified as annx-by-nu矩阵在哪里nx是州的数量和nuis the number of inputs.

状态到输出矩阵,指定为纽约-by-nx矩阵在哪里nx是州的数量和纽约is the number of outputs.

馈电矩阵,指定为纽约-by-nu矩阵在哪里纽约is the number of outputs andnuis the number of inputs.d也称为静态增益矩阵,该矩阵表示在稳态条件下输出与输入的比率。

m一个trix for implicit or descriptor state-space models, specified as anx-by-nx矩阵。eis empty by default, meaning that the state equation is explicit. To specify an implicit state equationedX/dt=斧头+bu,,,,settHis property to a square matrix of the same size as一个。Seedss有关创建描述符状态空间模型的更多信息。

逻辑值指示缩放是启用还是禁用,,,,specified as either0or1

WhenScaledis set to0((disabled), then most numerical algorithms acting on the state-space modelsys一个你tomatically rescale the state vector to improve numerical accuracy. You can prevent such auto-scaling by settingScaledto1((en一个bled).

For more information about scaling, seeprescale

State names, specified as one of the following:

  • CH一个r一个Ctervector — For first-order models, for example,'velocity'

  • Cell array of character vectors — For models with two or more states

StateNameis empty' '对于所有状态,默认情况下。

State path to facilitate state block path management in linearization, specified as one of the following:

  • CH一个r一个Ctervector — For first-order models

  • Cell array of character vectors — For models with two or more states

StatePathis empty' '对于所有状态,默认情况下。

State units, specified as one of the following:

  • CH一个r一个Ctervector — For first-order models, for example,'m/s'

  • Cell array of character vectors — For models with two or more states

Use国有保持trackof the units of each state.国有H一个sno effect on system behavior.国有is empty' '对于所有状态,默认情况下。

模型中的内部延迟,指定为向量。例如,当关闭有关延迟​​系统的系统或连接串联或并行连接延迟系统时,会出现内部延迟。有关内部延迟的更多信息,请参阅Closing Feedback Loops with Time Delays

For continuous-time models, internal delays are expressed in the time unit specified by theTimeUnitproperty of the model. For discrete-time models, internal delays are expressed as integer multiples of the sample timeTS。例如,InternalDelay = 3意味着三个采样周期的延迟。

You can modify the values of internal delays using the propertyInternalDelay。However, the number of entries insys。InternalDelayC一个nnot change, because it is a structural property of the model.

我nput delay for each input channel, specified as one of the following:

  • Scalar — Specify the input delay for a SISO system or the same delay for all inputs of a multi-input system.

  • nu-by-1矢量 - 指定单独的输入延迟以输入多输入系统,其中nuis the number of inputs.

For continuous-time systems, specify input delays in the time unit specified by theTimeUnit财产。For discrete-time systems, specify input delays in integer multiples of the sample time,TS

有关更多信息,请参阅线性系统中的时间延迟

Output delay for each output channel, specified as one of the following:

  • 标量 - 指定SISO系统的输出延迟或多输出系统所有输出的相同延迟。

  • 纽约-by-1vector — Specify separate output delays for output of a multi-output system, where纽约is the number of outputs.

For continuous-time systems, specify output delays in the time unit specified by theTimeUnit财产。For discrete-time systems, specify output delays in integer multiples of the sample time,TS

有关更多信息,请参阅线性系统中的时间延迟

Sample time, specified as:

  • 0用于连续时间系统。

  • 一个positive scalar representing the sampling period of a discrete-time system. SpecifyTSin the time unit specified by theTimeUnit财产。

  • -1for a discrete-time system with an unspecified sample time.

Note

CH一个ngingTS不离散或重新置换模型。要在连续时间和离散时间表示之间转换,请使用C2Dd2C。To change the sample time of a discrete-time system, used2d

Time variable units, specified as one of the following:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • “秒”

  • 'minutes'

  • 'hours'

  • 'days'

  • “周”

  • 'months'

  • '年'

CH一个ngingTimeUnitH一个sno effect on other properties, but changes the overall system behavior. UseCHgTimeUnitto convert between time units without modifying system behavior.

输入频道名称,指定为以下一个:

  • 一个CH一个r一个Ctervector, for single-input models.

  • 一个Cell array of character vectors, for multi-input models.

  • '',,,,no names specified, for any input channels.

一个lternatively, you can assign input names for multi-input models using automatic vector expansion. For example, ifsys是一个两输入模型,请输入以下内容:

sys。我nputName ='controls';

这input names automatically expand to{'controls(1)';'controls(2)'}

You can use the shorthand notationto refer to the我nputName财产。例如,sys。你等同于sys。我nputName

Use我nputNameto:

  • 我dentify channels on model display and plots.

  • eXtr一个Cts你bsystems of MIMO systems.

  • 互连模型时指定连接点。

我nput channel units, specified as one of the following:

  • 一个CH一个r一个Ctervector, for single-input models.

  • 一个Cell array of character vectors, for multi-input models.

  • '',,,,no units specified, for any input channels.

Use我nputUnitto specify input signal units.我nputUnitH一个sno effect on system behavior.

输入通道组,,,,specified as a structure. Use输入组to assign the input channels of MIMO systems into groups and refer to each group by name. The field names of输入组一个retHegroup names and the field values are the input channels of each group. For example, enter the following to create input groups named控件noisetH一个tinclude input channels12,,,,和35,,,,respectively.

sys。输入组。Controls = [1 2]; sys.InputGroup.noise = [3 5];

You can then extract the subsystem from the控件使用以下内容输入所有输出。

sys(:,'controls'

bydefault,输入组是一个没有字段的结构。

输出频道名称,,,,specified as one of the following:

  • 一个CH一个r一个Ctervector, for single-output models.

  • 字符向量的单元格数组,用于多输出模型。

  • '',,,,no names specified, for any output channels.

一个lternatively, you can assign output names for multi-output models using automatic vector expansion. For example, ifsysis a two-output model, enter the following.

sys.outputname ='measurements';

这output names automatically expand to{'measurements(1)';'measurements(2)'}

您也可以使用sHorthand notationyto refer to theOutputName财产。例如,sys。y等同于sys.outputname

UseOutputNameto:

  • 我dentify channels on model display and plots.

  • eXtr一个Cts你bsystems of MIMO systems.

  • 互连模型时指定连接点。

Output channel units, specified as one of the following:

  • 一个CH一个r一个Ctervector, for single-output models.

  • 字符向量的单元格数组,用于多输出模型。

  • '',对于任何输出通道,均未指定单位。

Useoutputunitto specify output signal units.outputunitH一个sno effect on system behavior.

Output channel groups, specified as a structure. UseOutputGroupto assign the output channels of MIMO systems into groups and refer to each group by name. The field names ofOutputGroup一个retHegroup names and the field values are the output channels of each group. For example, create output groups namedtemperature测量tH一个tinclude output channels1,,,,和35,,,,respectively.

sys。OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5];

You can then extract the subsystem from all inputs to the测量outputs using the following.

sys('测量',,,,:)

bydefault,OutputGroup是一个没有字段的结构。

系统名称,,,,specified as a character vector. For example,'system_1'

User-specified text that you want to associate with the system, specified as a character vector or cell array of character vectors. For example,“系统是Mimo”

您要与系统相关联的用户指定数据,指定为任何MATLAB数据类型。

Sampling grid for model arrays, specified as a structure array.

UseSamplingGrid跟踪模型数组中与每个模型关联的变量值,包括已识别的线性时间不变(IDLTI)模型阵列。

Set the field names of the structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables must be numeric scalars, and all arrays of sampled values must match the dimensions of the model array.

例如,you can create an 11-by-1 array of linear models,sys一个rr,,,,byt一个king snapshots of a linear time-varying system at timest=0:10。这following code stores the time samples with the linear models.

sysarr.samplinggrid = struct(struct('time',,,,0:10)

Similarly, you can create a 6-by-9 model array,m,通过独立采样两个变量,zetaw。这following code maps the((zeta,w)values tom

[zeta,w] = ndgrid(zeta>的<6值,<9值W>的值)m.samplinggrid = struct(struct(struct)('zeta',,,,zeta,'w',,,,w)

显示时m,,,,e一个CHentryin the array includes the correspondingzetaw值。

m
M(:,:,1,1) [zeta=0.3, w=5] = 25 -------------- s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25 ---------------- s^2 + 3.5 s + 25 ...

For model arrays generated by linearizing a Simulink®model at multiple parameter values or operating points, the software populatesSamplingGrid一个你tomatically with the variable values that correspond to each entry in the array. For instance, theSimulink Control Design™Commandslinearize((Simulink Control Design)slLinearizer((Simulink Control Design)populateSamplingGrid自动地。

bydefault,SamplingGrid是一个没有字段的结构。

Object Functions

这following lists contain a representative subset of the functions you can use withss模型对象。通常,任何适用于动态系统模型is applicable to anss目的。

eXpand all

step 动态系统的步骤响应图;步骤响应数据
impulse 动态系统的冲动响应图;冲动响应数据
lsim Plot simulated time response of dynamic system to arbitrary inputs; simulated response data
bode bode plot of frequency response, or magnitude and phase data
nyquist 纽约quist plot of frequency response
nichols Nichols chart of frequency response
带宽 Frequency response bandwidth
pole 动态系统
zero Zeros and gain of SISO dynamic system
pzplot 带有其他图自定义选项的动态系统模型的极点零图
利润 G一个in margin, phase margin, and crossover frequencies
zpk 零极成模型
tf Transfer function model
C2D 将模型从连续转换为离散时间
d2C Convert model from discrete to continuous time
d2d Resample discrete-time model
feedback Feedb一个Ck连接ion of multiple models
连接 block diagram interconnections of dynamic systems
series 两种型号的串联连接
parallel Parallel connection of two models
pidtune 线性植物模型的PID调整算法
rocus 动态系统的根基因座图
lqr 线性季节调节器(LQR)设计
lqg Linear-Quadratic-Gaussian (LQG) design
lqi Linear-Quadratic-Integral control
k一个lman design Kalman filter for state estimation

eX一个mples

Collapse all

创建定义的状态空间模型的输出ollowing state-space matrices:

一个 = [[ - 1 5 - 2 1 0 这是给予的 b = [[ 0 5 0 这是给予的 C = [[ 0 1 这是给予的 d = 0

Specify the A, B, C and D matrices, and create the state-space model.

a = [-1.5,-2; 1,0];b = [0.5; 0];C = [0,1];d = 0;sys = ss(a,b,c,d)
sys = a = x1 x2 x1 -1.5 -2 x2 1 0 b = u1 x1 0.5 x2 0 c = x1 x2 y1 0 1 d = u1 y1 0连续时间态空间模型。

状态空间模型创建一个样品时间为0。25seConds and the following state-space matrices:

一个 = [[ 0 1 - 5 - 2 这是给予的 b = [[ 0 3 这是给予的 C = [[ 0 1 这是给予的 d = [[ 0 这是给予的

Specify the state-space matrices.

a = [0 1; -5 -2];b = [0; 3];C = [0 1];d = 0;

指定样本时间。

TS=0。25;

Cre一个tetHest一个te-space model.

sys = ss(a,b,c,d,ts);

For this example, consider a cube rotating about its corner with inertia tensorj和一个d一个mping forceF0.2级。系统的输入是驱动扭矩,而角速度是输出。该立方体的状态空间矩阵是:

一个 = - j - 1 F ,,,, b = j - 1 ,,,, C = ,,,, d = 0 ,,,, w H e r e ,,,, j = [[ 8 - 3 - 3 - 3 8 - 3 - 3 - 3 8 这是给予的 一个 n d F = [[ 0 2 0 0 0 0 2 0 0 0 0 2 这是给予的

Specify the一个,,,,b,,,,Cdmatrices, and create the continuous-time state-space model.

j=[[8-3-3;-38-3;-3 -3 8]; F = 0.2*eye(3); A = -J\F; B = inv(J); C = eye(3); D = 0; sys = ss(A,B,C,D)
sys=一个=X1X2X3 x1 -0.04545 -0.02727 -0.02727 x2 -0.02727 -0.04545 -0.02727 x3 -0.02727 -0.02727 -0.04545 B = u1 u2 u3 x1 0.2273 0.1364 0.1364 x2 0.1364 0.2273 0.1364 x3 0.1364 0.1364 0.2273 C = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 D = u1 u2 u3 y1 0 0 0 y2 0 0 0 y3 0 0 0 Continuous-time state-space model.

sysis MIMO since the system contains 3 inputs and 3 outputs observed from matricesCd。有关MIMO州空间模型的更多信息,请参见MIMO状态空间模型

Cre一个te一个st一个te-space model using the following discrete-time, multi-input, multi-output state matrices with sample timeTS = 0.2seConds:

一个 = [[ - 7 0 0 - 1 0 这是给予的 b = [[ 5 0 0 2 这是给予的 C = [[ 1 - 4 - 4 0 5 这是给予的 d = [[ 0 - 2 2 0 这是给予的

Specify the state-space matrices and create the discrete-time MIMO state-space model.

一个=[[-7,,,,0;0,,,,-10这是给予的;b = [5,0;0,2]; C = [1,-4;-4,0.5]; D = [0,-2;2,0]; ts = 0.2; sys = ss(A,B,C,D,ts)
sys = a = x1 x2 x1 -7 0 x2 0 -10 b = u1 u2 x1 5 0 x2 0 2 c = x1 x2 y1 1 -4 y2 -4 0.5 d = u1 u2 y1 0 -2 y2 y2 2 0样品时间:0.2秒离散的状态空间模型。

Cre一个test一个te-space matrices and specify sample time.

a = [0 1; -5 -2];b = [0; 3];C = [0 1];d = 0;TS = 0.05;

Cre一个tetHest一个te-space model, specifying the state and input names using name-value pairs.

sys = ss(a,b,c,d,ts,'StateName',,,,{'Position''Velocity'},...'InputName',,,,'Force');

状态和输入名称的数量必须与一个,,,,b,,,,C,,,,和d

Naming the inputs and outputs can be useful when dealing with response plots for MIMO systems.

step(sys)

图包含一个轴对象。这一个Xesobject with title From: Force To: Out(1) contains an object of type line. This object represents sys.

Notice the input nameForcein the title of the step response plot.

For this example, create a state-space model with the same time and input unit properties inherited from another state-space model. Consider the following state-space models:

一个 1 = [[ - 1 5 - 2 1 0 这是给予的 b 1 = [[ 0 5 0 这是给予的 C 1 = [[ 0 1 这是给予的 d 1 = 5 一个 2 = [[ 7 - 1 0 2 这是给予的 b 2 = [[ 0 8 5 2 这是给予的 C 2 = [[ 1 0 1 4 这是给予的 d 2 = 2

First, create a state-space modelsys1with theTimeUnit我nputUnitproperty set to 'minutes'.

一个1=[[-1。5,,,,-2;1,,,,0这是给予的; B1 = [0.5;0]; C1 = [0,1]; D1 = 5; sys1 = ss(A1,B1,C1,D1,'TimeUnit',,,,'minutes',,,,“ inputunit”,,,,'minutes');

Verify that the time and input unit properties ofsys1一个resetto 'minutes'.

propvalues1 =[[sys1。TimeUnit,sys1.InputUnit]
propvalues1 =1X2Cell{'分钟'} {'分钟'}

Cre一个tetHeseCond state-space model with properties inherited fromsys1

一个2=[[7,,,,-1;0,,,,2这是给予的;b2 = [0.85;2]; C2 = [10,14]; D2 = 2; sys2 = ss(A2,B2,C2,D2,sys1);

Verify that the time and input units ofsys2已继承sys1

propValues2 = [sys2.TimeUnit,sys2.InputUnit]
propValues2 =1X2Cell{'分钟'} {'分钟'}

我ntHis example, you will create a static gain MIMO state-space model.

Consider the following two-input, two-output static gain matrix:

d = [[ 2 4 3 5 这是给予的

Specify the gain matrix and create the static gain state-space model.

d=[[2,,,,4;3,,,,5这是给予的;sys1 = ss(D)
sys1 = d = u1 u2 y1 2 4 y2 3 5静态增益。

计算以下传输函数的状态空间模型:

H (( s = [[ s + 1 s 3 + 3 s 2 + 3 s + 2 s 2 + 3 s 2 + s + 1 这是给予的

Cre一个tetHetr一个nsfer function model.

h = [tf([1 1],[1 3 3 2]);tf([1 0 3],[1 1 1])];

Convert this model to a state-space model.

sys = ss(H);

eX一个mine the size of the state-space model.

size(sys)
具有2个输出,1个输入和5个状态的状态空间模型。

状态的数量等于SISO条目的累积顺序H((s)。

To obtain a minimal realization ofH((s),,,,enter

sys = ss(H,,,,“最小”);size(sys)
State-space model with 2 outputs, 1 inputs, and 3 states.

这res你lting model has an order of three, which is the minimum number of states needed to representH((s)。To see this number of states, refactorH((s)作为一阶系统和二阶系统的乘积。

H (( s = [[ 1 s + 2 0 0 1 这是给予的 [[ s + 1 s 2 + s + 1 s 2 + 3 s 2 + s + 1 这是给予的

For this example, extract the measured and noise components of an identified polynomial model into two separate state-space models.

加载Box-Jenkins多项式模型ltiSysinidentifiedModel.mat

load('identifiedModel.mat',,,,'ltisys');

ltiSysis an identified discrete-time model of the form: y (( t = b F (( t + C d e (( t ,,,,在哪里 b F represents the measured component and C d tHenoise component.

将测量和噪声组件作为状态空间模型提取。

sysme一个s= ss(ltiSys,'measured'
sysme一个s=一个=X1X2 x1 1.575 -0.6115 x2 1 0 B = u1 x1 0.5 x2 0 C = x1 x2 y1 -0.2851 0.3916 D = u1 y1 0 Input delays (sampling periods): 2 Sample time: 0.04 seconds Discrete-time state-space model.
sysNoise = ss(ltiSys,'噪音'
sysNoise = A = x1 x2 x3 x1 1.026 -0.26 0.3899 x2 1 0 0 x3 0 0.5 0 B = v@y1 x1 0.25 x2 0 x3 0 C = x1 x2 x3 y1 0.319 -0.04738 0.07106 D = v@y1 y1 0.04556 Input groups: Name Channels Noise 1 Sample time: 0.04 seconds Discrete-time state-space model.

测得的组件可以用作植物模型,而噪声组件可以用作控制系统设计的干扰模型。

创建描述符状态空间模型(e)。

一个=[[2-4;42这是给予的;b= [-1; 0.5]; c = [-0.5, -2]; d = [-1]; e = [1 0; -3 0.5]; sysd = dss(a,b,c,d,e);

Compute an explicit realization of the system (e=)。

syse= ss(sysd,,,,'explicit'
syse=一个=X1X2 x1 2 -4 x2 20 -20 B = u1 x1 -1 x2 -5 C = x1 x2 y1 -0.5 -2 D = u1 y1 -1 Continuous-time state-space model.

Confirm that the descriptor and explicit realizations have equivalent dynamics.

bodeplot(sysd,syse,'g--'

图包含2个轴对象。斧头esobject 1 contains 2 objects of type line. These objects represent sysd, syse. Axes object 2 contains 2 objects of type line. These objects represent sysd, syse.

此示例显示了如何创建状态空间genss具有固定和可调参数的模型。

一个 = [[ 1 一个 + b 0 一个 b 这是给予的 ,,,, b = [[ - 3 0 1 5 这是给予的 ,,,, C = [[ 0 3 0 这是给予的 ,,,, d = 0 ,,,,

在哪里一个b是可调参数,其初始值为-13,,,,respectively.

Cre一个tetHet你n一个ble parameters usingre一个lp

一个=re一个lp('a',,,,-1);b=re一个lp('b',,,,3);

define a generalized matrix using algebraic expressions of一个b

一个=[[1一个+b;0一个*b];

一个是一个广义矩阵blocks属性包含一个b。初始值一个is[[12;0-3这是给予的,从初始值一个b

Cre一个tetHefixed-value state-space matrices.

b=[[-3。0;1。5这是给予的;C= [0.3 0]; D = 0;

Usessto create the state-space model.

sys = ss(a,b,c,d)
sys=Gener一个lized continuous-time state-space model with 1 outputs, 1 inputs, 2 states, and the following blocks: a: Scalar parameter, 2 occurrences. b: Scalar parameter, 2 occurrences. Type "ss(sys)" to see the current value, "get(sys)" to see all properties, and "sys.Blocks" to interact with the blocks.

sysis a generalized LTI model (genss)带有可调参数一个b

For this example, consider a SISO state-space model defined by the following state-space matrices:

一个 = [[ - 1 5 - 2 1 0 这是给予的 b = [[ 0 5 0 这是给予的 C = [[ 0 1 这是给予的 d = 0

Considering an input delay of 0.5 seconds and an output delay of 2.5 seconds, create a state-space model object to represent the A, B, C and D matrices.

a = [-1.5,-2; 1,0];b = [0.5; 0];C = [0,1];d = 0;sys = ss(a,b,c,d,'InputDelay',,,,0。5,,,,'OutputDelay',,,,2。5)
sys=一个=X1X2X1 -1.5 -2 x2 1 0 B = u1 x1 0.5 x2 0 C = x1 x2 y1 0 1 D = u1 y1 0 Input delays (seconds): 0.5 Output delays (seconds): 2.5 Continuous-time state-space model.

您也可以使用get命令显示MATLAB对象的所有属性。

get(sys)
一个: [2x2 double] B: [2x1 double] C: [0 1] D: 0 E: [] Scaled: 0 StateName: {2x1 cell} StatePath: {2x1 cell} StateUnit: {2x1 cell} InternalDelay: [0x1 double] InputDelay: 0.5000 OutputDelay: 2.5000 Ts: 0 TimeUnit: 'seconds' InputName: {''} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' SamplingGrid: [1x1 struct]

For more information on specifying time delay for an LTI model, seeSpecifying Time Delays

For this example, consider a state-space system object that represents the following state matrices:

一个 = [[ - 1 2 - 1 6 0 1 0 0 0 1 0 这是给予的 ,,,, b = [[ 1 0 0 这是给予的 ,,,, C = [[ 0 0 5 1 3 这是给予的 ,,,, d = 0 ,,,, State-space matrices

Cre一个te一个st一个te-space objectsys你sing thessCommand.

一个=[[-1。2,,,,-1。6,,,,0;1,,,,0,0;0,1,0]; B = [1;0;0]; C = [0,0.5,1.3]; D = 0; sys = ss(A,B,C,D);

接下来,计算单位负增益的闭环状态空间模型,并找到闭环状态空间系统对象的电线杆sysFeedb一个Ck

sysFeedb一个Ck=feedback(sys,1); P = pole(sysFeedback)
p =3×1Complex-0。2305+1。3062i -0.2305 - 1.3062i -0.7389 + 0.0000i

这feedback loop for unit gain is stable since all poles have negative real parts. Checking the closed-loop poles provides a binary assessment of stability. In practice, it is more useful to know how robust (or fragile) stability is. One indication of robustness is how much the loop gain can change before stability is lost. You can use the root locus plot to estimate the range ofkvalues for which the loop is stable.

rocus((sys)

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

CH一个nges in the loop gain are only one aspect of robust stability. In general, imperfect plant modeling means that both gain and phase are not known exactly. Since modeling errors have the most detrimental effect near the gain crossover frequency (frequency where open-loop gain is 0dB), it also matters how much phase variation can be tolerated at this frequency.

You can display the gain and phase margins on a Bode plot as follows.

bode(sys) grid

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

For a more detailed example, see一个ssessing Gain and Phase Margins

对于这个例子,设计一个二自由度PID控制器witH一个t一个rget bandwidth of 0.75 rad/s for a system represented by the following matrices:

一个 = [[ - 0 5 - 0 1 1 0 这是给予的 ,,,, b = [[ 1 0 这是给予的 ,,,, C = [[ 0 1 这是给予的 ,,,, d = 0

Cre一个te一个st一个te-space objectsys你sing thessCommand.

一个=[[-0。5,,,,-0。1;1,,,,0这是给予的; B = [1;0]; C = [0,1]; D = 0; sys = ss(A,B,C,D)
sys=一个=X1X2X1 -0.5 -0.1 x2 1 0 B = u1 x1 1 x2 0 C = x1 x2 y1 0 1 D = u1 y1 0 Continuous-time state-space model.

Using the target bandwidth, usepidtuneto generate a 2-DOF controller.

wC=0。75;C2=pidtune(sys,'pid2',,,,wC)
c2 = 1 u = kp(b*r-y) + ki ---(r-y) + kd*s(c*r-y)s,kp = 0.513,ki = 0.0975,kd = 0.577,b = 0.344,c = 0- 平行形式的时间二-DOF PID控制器。

Using the type'pid2'C一个你sespidtuneto generate a 2-DOF controller, represented as aPID2目的。这display confirms this result. The display also shows thatpidtunet你nes一个ll controller coefficients, including the setpoint weightsbC,,,,to balance performance and robustness.

For interactive PID tuning in the Live Editor, see theTune PID控制器Live Editor task. This task lets you interactively design a PID controller and automatically generates MATLAB code for your live script.

For interactive PID tuning in a standalone app, usePID Tuner。SeePID Controller Design for Fast Reference Trackingfor an example of designing a controller using the app.

考虑一个州空间植物Gwith five inputs and four outputs and a state-space feedback controllerk有三个输入和两个输出。植物的输出1、3和4Gmust be connected the controllerkinputs, and the controller outputs to inputs 4 and 2 of the plant.

For this example, consider two continuous-time state-space models for bothGkrepresented by the following set of matrices:

一个 G = [[ - 3 0 4 0 3 - 0 5 - 2 8 - 0 8 0 2 0 8 - 3 这是给予的 ,,,, b G = [[ 0 4 0 0 3 0 2 0 - 0 2 - 1 0 1 - 0 9 - 0 5 0 6 0 9 0 5 0 2 0 这是给予的 ,,,, C G = [[ 0 - 0 1 - 1 0 - 0 2 1 6 - 0 7 1 5 1 2 - 1 4 - 0 2 0 这是给予的 ,,,, d G = [[ 0 0 0 0 - 1 0 0 4 - 0 7 0 0 9 0 0 3 0 0 0 0 2 0 0 0 0 这是给予的

一个 k = [[ - 0 2 2 1 0 7 - 2 2 - 0 1 - 2 2 - 0 4 2 3 - 0 2 这是给予的 ,,,, b k = [[ - 0 1 - 2 1 - 0 3 - 0 1 0 0 6 1 0 0 8 这是给予的 ,,,, C k = [[ - 1 0 0 - 0 4 - 0 2 0 3 这是给予的 ,,,, d k = [[ 0 0 0 0 0 - 1 2 这是给予的

ag = [-3,0.4,0.3; -0.5,-2.8,-0.8; 0.2,0.8,-3];bg = [0.4,0,0.3,0.2,0; -0.2,-1,0.1,-0.9,-0.5; 0.6,0.9,0.5,0.2,0.2,0];cg = [0,-0.1,-1; 0,-0.2,1.6; -0.7,1.5,1.2; -1.4,-0.2,0];dg = [0,0,0,0,-1; 0,0.4,-0.7,0,0.9; 0,0.0.3,0,0,0; ​​0.2,0,0,0,0,0];SYSG = SS(AG,BG,CG,DG)
sysG=一个=X1X2 x3 x1 -3 0.4 0.3 x2 -0.5 -2.8 -0.8 x3 0.2 0.8 -3 B = u1 u2 u3 u4 u5 x1 0.4 0 0.3 0.2 0 x2 -0.2 -1 0.1 -0.9 -0.5 x3 0.6 0.9 0.5 0.2 0 C = x1 x2 x3 y1 0 -0.1 -1 y2 0 -0.2 1.6 y3 -0.7 1.5 1.2 y4 -1.4 -0.2 0 D = u1 u2 u3 u4 u5 y1 0 0 0 0 -1 y2 0 0.4 -0.7 0 0.9 y3 0 0.3 0 0 0 y4 0.2 0 0 0 0 Continuous-time state-space model.
一个k=[[-0。2,,,,2。1,,,,0。7;-2。2,-0.1,-2.2;-0.4,2.3,-0.2]; BK = [-0.1,-2.1,-0.3;-0.1,0,0.6;1,0,0.8]; CK = [-1,0,0;-0.4,-0.2,0.3]; DK = [0,0,0;0,0,-1.2]; sysK = ss(AK,BK,CK,DK)
sysk = a = x1 x2 x3 x1 -0.2 2.1 0.7 x2 -2.2 -2.2 -0.1 -2.2 x3 -0.4 2.3 -0.2 b = u1 u1 u2 u3 u3 x1 -0.1 -2.1 -0.3 x2 -0.3 x2 -0.1 0.6 x3 1 0.6 x3 1 0 0.8 C = x1 x2X3 Y1 -1 0 0 Y2 -0.4 -0.2 0.3 D = U1 U2 U3 Y1 0 0 0 0 0 Y2 0 0 -1.2连续时空空间模型。

define thefeedout饲料中基于要在反馈循环中连接的输入和输出的向量。

feedin = [4 2];feedOut = [1 3 4];sys =反馈(SYSG,SYSK,feedin,feedout,-1)
sys = A = x1 x2 x3 x4 x5 x6 x1 -3 0.4 0.3 0.2 0 0 x2 1.18 -2.56 -0.8 -1.3 -0.2 0.3 x3 -1.312 0.584 -3 0.56 0.18 -0.27 x4 2.948 -2.929 -2.42 -0.452 1.974 0.889 x5-0.84 -0.11 0.1 -2.2 -0.1 -2.2 x6 -1.12 -0.26 -1 -0.4 2.3 -0.2 B = u1 u2 u3 u4 u5 x1 0.4 0 0.3 0.2 0 x2 -0.44 -1 0.1 -0.9 -0.5 x3 0.816 0.9 0.50.2 0 x4 -0.2112 -0.63 0 0 0 0.1 x5 0.12 0 0 0 0 0 0 0 0.1 x6 0.16 0 0 0 0 0 0 -1 c = x1 x2 x3 x3 x4 x5 x5 x6 y1 0 -0.1 -1 0 0 0 0 0 0 y2 -0.672 -0.296 1.6 0.6 0.16 0.16 0.16 0.08 -0.12y3 -1.204 1.428 1.2 0.12 0.06 -0.09 y4 -1.4 -0.2 0 0 0 0 D = u1 u2 u3 u4 u5 y1 0 0 0 0 -1 y2 0.096 0.4 -0.7 0 0.9 y3 0.072 0.3 0 0 0 y4 0.2 0 0 00连续时空空间模型。
size(sys)
State-space model with 4 outputs, 5 inputs, and 6 states.

sysis the resultant closed loop state-space model obtained by connecting the specified inputs and outputs ofGk

Version History

我ntroduced before R2006a