使用矩阵数据进行时域系统辨识
在 System Identification Toolbox™ 中表示数据的最简单方法是使用数值矩阵,其中一个矩阵用于输入数据,另一个矩阵用于输出数据。观测数据沿行排列,通道沿列排列。这种数据格式通常足以用于辨识离散时间模型。请注意,此格式不提供有关时间向量的任何信息。因此,不推荐使用这种格式来辨识连续时间模型。
估计离散时间模型
例如,根据矩阵数据估计一个离散时间模型。将矩阵指定为以逗号分隔的配对形式 。
load sdata1 umat1 ymat1 sysd = n4sid(umat1, ymat1, 4)
sysd =
Discrete-time identified state-space model:
x(t+Ts) = A x(t) + B u(t) + K e(t)
y(t) = C x(t) + D u(t) + e(t)
A =
x1 x2 x3 x4
x1 0.8392 0.3129 -0.02105 0.03743
x2 -0.4768 0.6671 0.1428 -0.003757
x3 0.01951 0.08374 -0.09761 -1.046
x4 -0.003885 0.02914 0.8796 -0.03171
B =
u1
x1 0.02635
x2 0.03301
x3 -7.256e-05
x4 0.0005861
C =
x1 x2 x3 x4
y1 69.08 -26.64 2.237 -0.5601
D =
u1
y1 0
K =
y1
x1 0.003282
x2 -0.009339
x3 0.003232
x4 0.003809
Sample time: 1 seconds
Parameterization:
FREE form (all coefficients in A, B, C free).
Feedthrough: none
Disturbance component: estimate
Number of free coefficients: 28
Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using N4SID on time domain data "umat1,ymat1".
Fit to estimation data: 76.33% (prediction focus)
FPE: 1.21, MSE: 1.087
Model Properties
查看示例时间。
sysd.Ts
ans = 1
由于数据中未提供采样时间,因此软件默认数据采样时间为 1 秒。因此,模型的采样时间 sysd.Ts 也是 1 秒(请注意,n4sid 默认估计的是离散时间模型。)
由于数据中未提供采样时间信息,您可以使用 'Ts'/<value> 的名称-值参量为模型指定不同的采样时间。将模型采样时间设置为 0.1 秒。
sysd = n4sid(umat1, ymat1, 4, 'Ts', 0.1);该软件假设数据采样时间也是 0.1 秒。
估计连续时间模型
如果目的是通过将 Ts 设置为 0 来指定一个连续时间模型,那么仅指定采样时间是行不通的。
sysc = n4sid(umat1, ymat1, 4, 'Ts', 0);Warning: Data sample time is assumed to be 1 seconds. To specify a different value for the data sample time consider providing data using a timetable or an iddata object.
在这种情况下,没有直接的方法来指定数据采样时间。该软件默认数据采样时间为 1 秒,并发出警告。
若要估计连续时间模型,必须将其转换为时间表或 iddata 对象,以便指定数据采样时间信息。
假设上述数据的真实采样时间为 0.1 小时。利用数据采样时间信息,将数据转换为时间表。
N = size(umat1,1); % (assume a start time of 1 hr) t = hours(0.1*(1:N)'); dataTT = timetable(umat1,ymat1,'RowTimes',t);
现在可以对连续模型进行估计了。
sysc = n4sid(dataTT, 4, 'Ts', 0);
sysc.Tsans = 0
sysc.TimeUnit
ans = 'hours'
此外,除了将数据转换为时间表外,您还可以将其转换为 iddata 对象。请注意,iddata 的转换命令先指定输出,而 timetable 命令则先指定输入。
dataIDDATA = iddata(ymat1, umat1, 0.1, 'TimeUnit', 'hours'); sysc = n4sid(dataIDDATA, 4, 'Ts', 0); sysc.Ts
ans = 0
sysc.TimeUnit
ans = 'hours'
估计时间序列模型
对于时间序列数据,即仅包含输出数据而无输入数据的数据,请指定 []、。
systs = n4sid([],ymat1,4)
systs =
Discrete-time identified state-space model:
x(t+Ts) = A x(t) + K e(t)
y(t) = C x(t) + e(t)
A =
x1 x2 x3 x4
x1 0.8293 -0.4941 -0.0201 0.2288
x2 0.2122 0.6994 -0.03311 0.5703
x3 -0.01299 0.03653 -0.8259 0.7642
x4 0.007749 -0.04922 -0.3883 -0.1022
C =
x1 x2 x3 x4
y1 -74.48 14.6 0.6196 -0.1086
K =
y1
x1 -0.01566
x2 0.006688
x3 -0.0009932
x4 0.0005739
Sample time: 1 seconds
Parameterization:
FREE form (all coefficients in A, B, C free).
Disturbance component: estimate
Number of free coefficients: 24
Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using N4SID on time domain data "ymat1".
Fit to estimation data: 59.64% (prediction focus)
FPE: 3.425, MSE: 3.161
Model Properties
systs 是一种不包含 或 组件的时间序列模型。