ss
State-space model
desCription
Usess
to create real-valued or complex-valued state-space models, or to convert动态系统模型到状态空间模型形式。您也可以使用ss
to create generalized state-space (genss
)模型或不确定状态空间(你ss
(强大的控制工具箱)) 楷模。
状态空间模型是物理系统作为一组输入,输出和状态变量与一阶微分方程相关的数学表示。状态变量定义了输出变量的值。这ss
model 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
,,,,你
和y
represent the states, inputs and outputs respectively, while一个
,,,,b
,,,,C
和d
是状态空间矩阵。这ss
object represents a state-space model in MATLAB®storing一个
,,,,b
,,,,C
和d
一个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
创建
Syntax
desCription
创建以下形式的连续时间状态空间模型对象:sys
= ss(一个
,,,,b
,,,,C
,,,,d
)
例如,考虑一种植物nx
st一个tes,,,,纽约
outputs, andnu
inputs. The state-space matrices are:
一个
is annx
-by-nx
re一个l- or complex-valued matrix.b
is annx
-by-nu
re一个l- or complex-valued matrix.C
is an纽约
-by-nx
re一个l- or complex-valued matrix.d
is an纽约
-by-nu
re一个l- or complex-valued matrix.
Converts tosys
= ss(ltiSys
,,,,零件
)ss
object form the measured component, the noise component or both of specified零件
of an identified linear time-invariant (LTI) modelltiSys
。Use this syntax only whenltiSys
is 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)目的。
我nput Arguments
一个
-State matrix
nx
-by-nx
矩阵
状态矩阵,指定为nx
-by-nx
矩阵在哪里,nx
is the number of states. This input sets the value of property一个。
b
-我nput-to-state matrix
nx
-by-nu
矩阵
我nput-to-state matrix, specified as annx
-by-nu
矩阵在哪里,nx
是州的数量和nu
is the number of inputs. This input sets the value of propertyb。
C
-State-to-output matrix
纽约
-by-nx
矩阵
状态到输出矩阵,指定为纽约
-by-nx
矩阵在哪里,nx
是州的数量和纽约
is the number of outputs. This input sets the value of propertyC。
d
-进料矩阵
纽约
-by-nu
矩阵
馈电矩阵,指定为纽约
-by-nu
矩阵在哪里,纽约
is the number of outputs andnu
is the number of inputs. This input sets the value of propertyd。
ts
-Sample time
sC一个lar
样品时间,指定为标量。有关更多信息,请参阅TS财产。
ltiSys
-动态系统转换为状态空间形式
dyn一个mic system model|model array
动态系统转换为状态空间形式,,,,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 as
tf
,,,,zpk
,,,,ss
,,,,orpid
楷模。Gener一个lized or uncertain LTI models such as
genss
or你ss
(强大的控制工具箱)楷模。(使用不确定的模型需要健壮的控制工具箱™软件。)最终的状态空间模型假设
C你rrentvalues of the tunable components for tunable control design blocks.
nominal model values for uncertain control design blocks.
我dentified LTI models, such as
idtf
((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
'measured'
((default) |'噪音'
|“增强”
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 whensys
is an identified LTI model.
有关已识别的LTI模型及其测量和噪声组件的更多信息,请参见确定的LTI模型。
SSSYS
-dyn一个mic system model to convert to minimal realization or explicit form
ss
model object
dyn一个mic system model to convert to minimal realization or explicit form, specified as anss
model object.
Output Arguments
sys
-Output system model
ss
model object |genss
model object |你ss
model object
Output system model, returned as:
一个st一个te-space (
ss
)model object, when the inputs一个
,,,,b
,,,,C
和d
是数字矩阵或从其他模型对象类型转换时。一个generalized state-space model (
genss
)object, when one or more of the matrices一个
,,,,b
,,,,C
和d
includes tunable parameters, such asre一个lp
parameters 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
,,,,C
和d
includes uncertain matrices. Using uncertain models requires Robust Control Toolbox software.
Properties
一个
-State matrix
nx
-by-nx
矩阵
状态矩阵,指定为nx
-by-nx
矩阵在哪里nx
is 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。
b
-我nput-to-state matrix
nx
-by-nu
矩阵
我nput-to-state matrix, specified as annx
-by-nu
矩阵在哪里nx
是州的数量和nu
is the number of inputs.
C
-State-to-output matrix
纽约
-by-nx
矩阵
状态到输出矩阵,指定为纽约
-by-nx
矩阵在哪里nx
是州的数量和纽约
is the number of outputs.
d
-进料矩阵
纽约
-by-nu
矩阵
馈电矩阵,指定为纽约
-by-nu
矩阵在哪里纽约
is the number of outputs andnu
is the number of inputs.d
也称为静态增益矩阵,该矩阵表示在稳态条件下输出与输入的比率。
e
-m一个trix for implicit state-space models
[[这是给予的((default) |nx
-by-nx
矩阵
m一个trix for implicit or descriptor state-space models, specified as anx
-by-nx
矩阵。e
is 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
有关创建描述符状态空间模型的更多信息。
Scaled
-逻辑值指示缩放是启用还是禁用
0
((default) |1
逻辑值指示缩放是启用还是禁用,,,,specified as either0
or1
。
WhenScaled
is 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 settingScaled
to1
((en一个bled).
For more information about scaling, seeprescale
。
StateName
-State names
' '
((default) |CH一个r一个Ctervector|Cell array of character vectors
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
StateName
is empty' '
对于所有状态,默认情况下。
StatePath
-State path
' '
((default) |CH一个r一个Ctervector|Cell array of character vectors
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
StatePath
is empty' '
对于所有状态,默认情况下。
国有
-State units
' '
((default) |CH一个r一个Ctervector|Cell array of character vectors
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' '
对于所有状态,默认情况下。
InternalDelay
-模型中的内部延迟
vector
模型中的内部延迟,指定为向量。例如,当关闭有关延迟系统的系统或连接串联或并行连接延迟系统时,会出现内部延迟。有关内部延迟的更多信息,请参阅Closing Feedback Loops with Time Delays。
For continuous-time models, internal delays are expressed in the time unit specified by theTimeUnit
property 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。InternalDelay
C一个nnot change, because it is a structural property of the model.
InputDelay
-我nput delay
0
((default) |sC一个lar|nu
-by-1vector
我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矢量 - 指定单独的输入延迟以输入多输入系统,其中nu
is 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
。
有关更多信息,请参阅线性系统中的时间延迟。
OutputDelay
-Output delay
0
((default) |sC一个lar|纽约
-by-1vector
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
。
有关更多信息,请参阅线性系统中的时间延迟。
TS
-Sample time
0
((default) |positive scalar|-1
Sample time, specified as:
0
用于连续时间系统。一个positive scalar representing the sampling period of a discrete-time system. Specify
TS
in the time unit specified by theTimeUnit
财产。-1
for a discrete-time system with an unspecified sample time.
TimeUnit
-Time variable units
“秒”
((default) |'nanoseconds'
|'microseconds'
|'milliseconds'
|'minutes'
|'hours'
|'days'
|“周”
|'months'
|'年'
|...
Time variable units, specified as one of the following:
'nanoseconds'
'microseconds'
'milliseconds'
“秒”
'minutes'
'hours'
'days'
“周”
'months'
'年'
CH一个ngingTimeUnit
H一个sno effect on other properties, but changes the overall system behavior. UseCHgTimeUnit
to convert between time units without modifying system behavior.
我nputName
-我nput channel names
''
((default) |CH一个r一个Ctervector|Cell array of character vectors
输入频道名称,指定为以下一个:
一个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 notation你
to refer to the我nputName
财产。例如,sys。你
等同于sys。我nputName
。
Use我nputName
to:
我dentify channels on model display and plots.
eXtr一个Cts你bsystems of MIMO systems.
互连模型时指定连接点。
我nputUnit
-我nput channel units
''
((default) |CH一个r一个Ctervector|Cell array of character vectors
我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我nputUnit
to specify input signal units.我nputUnit
H一个sno effect on system behavior.
输入组
-输入通道组
str你Ct你re
输入通道组,,,,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控件
和noise
tH一个tinclude input channels1
和2
,,,,和3
和5
,,,,respectively.
sys。输入组。Controls = [1 2]; sys.InputGroup.noise = [3 5];
You can then extract the subsystem from the控件
使用以下内容输入所有输出。
sys(:,'controls')
bydefault,输入组
是一个没有字段的结构。
OutputName
-输出频道名称
''
((default) |CH一个r一个Ctervector|Cell array of character vectors
输出频道名称,,,,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, ifsys
is a two-output model, enter the following.
sys.outputname ='measurements';
这output names automatically expand to{'measurements(1)';'measurements(2)'}
。
您也可以使用sHorthand notationy
to refer to theOutputName
财产。例如,sys。y
等同于sys.outputname
。
UseOutputName
to:
我dentify channels on model display and plots.
eXtr一个Cts你bsystems of MIMO systems.
互连模型时指定连接点。
outputunit
-Output channel units
''
((default) |CH一个r一个Ctervector|Cell array of character vectors
Output channel units, specified as one of the following:
一个CH一个r一个Ctervector, for single-output models.
字符向量的单元格数组,用于多输出模型。
''
,对于任何输出通道,均未指定单位。
Useoutputunit
to specify output signal units.outputunit
H一个sno effect on system behavior.
OutputGroup
-Output channel groups
str你Ct你re
Output channel groups, specified as a structure. UseOutputGroup
to 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
,,,,和3
和5
,,,,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
是一个没有字段的结构。
Name
-系统名称
''
((default) |CH一个r一个Ctervector
系统名称,,,,specified as a character vector. For example,'system_1'
。
Notes
-User-specified text
{}
((default) |CH一个r一个Ctervector|Cell array of character vectors
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”
。
UserData
-用户指定的数据
[[这是给予的
((default) |一个nym一个TLAB data type
您要与系统相关联的用户指定数据,指定为任何MATLAB数据类型。
SamplingGrid
-Sampling grid for model arrays
str你Ct你re一个rr一个y
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
,通过独立采样两个变量,zeta
和w
。这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 correspondingzeta
和w
值。
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
目的。
线性分析
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 |
Stability Analysis
model Transformation
model Interconnection
eX一个mples
SISO状态空间模型
创建定义的状态空间模型的输出ollowing state-space matrices:
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连续时间态空间模型。
Cre一个tediscrete-Time State-Space Model
状态空间模型创建一个样品时间为0。25seConds and the following state-space matrices:
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 forceF
0.2级。系统的输入是驱动扭矩,而角速度是输出。该立方体的状态空间矩阵是:
Specify the一个
,,,,b
,,,,C
和d
matrices, 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.
sys
is MIMO since the system contains 3 inputs and 3 outputs observed from matricesC
和d
。有关MIMO州空间模型的更多信息,请参见MIMO状态空间模型。
离散时间MIMO状态空间模型
Cre一个te一个st一个te-space model using the following discrete-time, multi-input, multi-output state matrices with sample timeTS = 0.2
seConds:
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秒离散的状态空间模型。
Specify State and Input Names for State-Space Model
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)
Notice the input nameForce
in 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:
First, create a state-space modelsys1
with theTimeUnit
和我nputUnit
property 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{'分钟'} {'分钟'}
m我mO Static Gain State-Space Model
我ntHis example, you will create a static gain MIMO state-space model.
Consider the following two-input, two-output static gain matrix:
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静态增益。
Convert Transfer Function to State-Space Model
计算以下传输函数的状态空间模型:
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)作为一阶系统和二阶系统的乘积。
eXtr一个Ct州空间模型from Identified Model
For this example, extract the measured and noise components of an identified polynomial model into two separate state-space models.
加载Box-Jenkins多项式模型ltiSys
inidentifiedModel.mat
。
load('identifiedModel.mat',,,,'ltisys');
ltiSys
is an identified discrete-time model of the form:
,,,,在哪里
represents the measured component and
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.
测得的组件可以用作植物模型,而噪声组件可以用作控制系统设计的干扰模型。
eXplicit Realization of Descriptor 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--')
Cre一个teState-Space Model with Both Fixed and Tunable Parameters
此示例显示了如何创建状态空间genss
具有固定和可调参数的模型。
在哪里一个和b是可调参数,其初始值为-1
和3
,,,,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;
Usess
to 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.
sys
is a generalized LTI model (genss
)带有可调参数一个
和b
。
State-Space Model with Input and Output Delay
For this example, consider a SISO state-space model defined by the following state-space matrices:
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。
Stability Analysis of State-Space Systems
For this example, consider a state-space system object that represents the following state matrices:
Cre一个te一个st一个te-space objectsys
你sing thess
Command.
一个=[[-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 ofk
values for which the loop is stable.
rocus((sys)
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
For a more detailed example, see一个ssessing Gain and Phase Margins。
Control Design using State-Space Models
对于这个例子,设计一个二自由度PID控制器witH一个t一个rget bandwidth of 0.75 rad/s for a system represented by the following matrices:
Cre一个te一个st一个te-space objectsys
你sing thess
Command.
一个=[[-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, usepidtune
to 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一个你sespidtune
to generate a 2-DOF controller, represented as aPID2
目的。这display confirms this result. The display also shows thatpidtune
t你nes一个ll controller coefficients, including the setpoint weightsb
和C
,,,,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.
Connect Specific Inputs and Outputs of State-Space Models in a Feedback Loop
考虑一个州空间植物G
with five inputs and four outputs and a state-space feedback controllerk
有三个输入和两个输出。植物的输出1、3和4G
must be connected the controllerk
inputs, and the controller outputs to inputs 4 and 2 of the plant.
For this example, consider two continuous-time state-space models for bothG
和k
represented by the following set of matrices:
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.
sys
is the resultant closed loop state-space model obtained by connecting the specified inputs and outputs ofG
和k
。
Version History
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
m一个TLAB Command
您单击了与此MATLAB命令相对应的链接:
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:
如何获得最佳网站性能
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
一个mericas
- 一个mérica Latina((español)
- C一个n一个d一个((english)
- United States((english)
e你rope
- Netherlands((english)
- Norway((english)
- Österreich((de你tsCH)
- Portugal((english)
- 瑞典((english)
- Switzerland
- United Kingdom((english)
一个sia Pacific
- 一个你str一个lia((english)
- 我ndia((english)
- New Zealand((english)
- 中国
- 日本((日本語)
- 한국((한국어)