greyest
Estimate ODE parameters of linear grey-box model
Description
incorporates a sys
= greyest(data
,init_sys
,opt
)greyestOptions
option set
opt
that specifies options such as handling of initial states and
regularization options.
Examples
Estimate Grey-Box Model
Estimate the parameters of a DC motor using the linear grey-box framework.
Load the measured data.
load('dcmotordata'); data = iddata(y, u, 0.1, 'Name', 'DC-motor'); data.InputName = 'Voltage'; data.InputUnit = 'V'; data.OutputName = {'Angular position', 'Angular velocity'}; data.OutputUnit = {'rad', 'rad/s'}; data.Tstart = 0; data.TimeUnit = 's';
data
is an iddata
object containing the measured data for the outputs, the angular position, the angular velocity. It also contains the input, the driving voltage.
Create a grey-box model representing the system dynamics.
For the DC motor, choose the angular position (rad) and the angular velocity (rad/s) as the outputs and the driving voltage (V) as the input. Set up a linear state-space structure of the following form:
is the time constant of the motor in seconds, and is the static gain from the input to the angular velocity in rad/(V*s).
G = 0.25; tau = 1; init_sys = idgrey('motorDynamics',tau,'cd',G,0);
The governing equations in state-space form are represented in the MATLAB® file motorDynamics.m
. To view the contents of this file, enter edit motorDynamics.m
at the MATLAB command prompt.
is a known quantity that is provided to motorDynamics.m
as an optional argument.
is a free estimation parameter.
init_sys
is an idgrey
model associated with motor.m
.
Estimate .
sys = greyest(data,init_sys);
sys
is an idgrey
model containing the estimated value of .
To obtain the estimated parameter values associated with sys
, use getpvec(sys)
.
Analyze the result.
opt = compareOptions('InitialCondition','zero'); compare(data,sys,Inf,opt)
sys
provides a 98.35% fit for the angular position and an 84.42% fit for the angular velocity.
Estimate Grey-Box Model Using Regularization
Estimate the parameters of a DC motor by incorporating prior information about the parameters when using regularization constants.
The model is parameterized by static gain G
and time constant . From prior knowledge, it is known that G
is about 4 and is about 1. Also, you have more confidence in the value of than G
and would like to guide the estimation to remain close to the initial guess.
Load estimation data.
load regularizationExampleData.mat motorData
The data contains measurements of motor's angular position and velocity at given input voltages.
Create an idgrey
model for DC motor dynamics. Use the function DCMotorODE
that represents the structure of the grey-box model.
mi = idgrey(@DCMotorODE,{'G', 4; 'Tau', 1},'cd',{}, 0); mi = setpar(mi, 'label', 'default');
If you want to view the DCMotorODE
function, type:
type DCMotorODE.m
function [A,B,C,D] = DCMotorODE(G,Tau,Ts) %DCMOTORODE ODE file representing the dynamics of a DC motor parameterized %by gain G and time constant Tau. % % [A,B,C,D,K,X0] = DCMOTORODE(G,Tau,Ts) returns the state space matrices % of the DC-motor with time-constant Tau and static gain G. The sample % time is Ts. % % This file returns continuous-time representation if input argument Ts % is zero. If Ts>0, a discrete-time representation is returned. % % See also IDGREY, GREYEST. % Copyright 2013 The MathWorks, Inc. A = [0 1;0 -1/Tau]; B = [0; G/Tau]; C = eye(2); D = [0;0]; if Ts>0 % Sample the model with sample time Ts s = expm([[A B]*Ts; zeros(1,3)]); A = s(1:2,1:2); B = s(1:2,3); end
Specify regularization options Lambda.
opt = greyestOptions; opt.Regularization.Lambda = 100;
Specify regularization options R.
opt.Regularization.R = [1, 1000];
You specify more weighting on the second parameter because you have more confidence in the value of than G
.
Specify the initial values of the parameters as regularization option *.
opt.Regularization.Nominal = 'model';
Estimate the regularized grey-box model.
sys = greyest(motorData, mi, opt);
Input Arguments
data
— Estimation data
timetable | numeric matrix pair | iddata
object | frd
object | idfrd
object
Uniformly sampled estimation data, specified as a timetable, a comma-separated matrix pair, or a time-domain or frequency-domain data object, as the following sections describe.
data
has the same input and output dimensions as
init_sys
.
By default, the software sets the sample time of the model to the sample time of the estimation data.
Timetable
Specify data
as a timetable
that uses a regularly spaced time vector.
data
contains variables representing input and output
channels.
Comma-Separated Matrix Pair
Specify data
as a comma-separated pair of numeric matrices
that contain input and output time-domain signal values. Use this
data
specification only for discrete-time systems.
Data Object
Specify data as an iddata
, idfrd
, or
frd
object.
For time-domain estimation,
data
must be a time-domainiddata
object containing the input and output signal values.For frequency-domain estimation,
data
can be one of the following:
For more information about working with estimation data types, see Data Domains and Data Types in System Identification Toolbox.
opt
— Estimation options
greyestOptions
option set
Estimation options, specified as a greyestOptions
option set. Options specified by opt
include:
Handling of initial states
Regularization
Numerical search method used for estimation
Output Arguments
sys
— Identified linear grey-box model
idgrey
model
Estimated grey-box model, returned as an idgrey
model. This model is created using the specified initial system,
and estimation options.
Information about the estimation results and options used is stored in
the Report
property of the model.
Report
has the following fields:
Report Field | Description |
---|---|
Status | Summary of the model status, which indicates whether the model was created by construction or obtained by estimation |
Method | Estimation command used |
InitialState | Handling of initial states during estimation, returned as one of the following:
This field is especially useful to view how the initial
states were handled when the |
DisturbanceModel | Handling of the disturbance component (K) during estimation, returned as one of the following values:
This field is especially useful to view the how the
disturbance component was handled when the |
Fit | Quantitative assessment of the estimation, returned as a structure. See Loss Function and Model Quality Metrics for more information on these quality metrics. The structure has these fields.
|
Parameters | Estimated values of model parameters |
OptionsUsed | Option set used for estimation. If no custom options were configured,
this is a set of default options. See |
RandState | State of the random number stream at the start of estimation. Empty,
|
DataUsed | Attributes of the data used for estimation, returned as a structure with the following fields.
|
Termination | Termination conditions for the iterative search used for prediction error minimization, returned as a structure with these fields.
For estimation methods that do not require numerical search
optimization, the |
For more information on using Report
, see Estimation Report.
x0
— Initial states
matrix
Initial states computed during the estimation, returned as a matrix containing a column vector corresponding to each experiment.
This array is also stored in the Parameters
field of the model
Report
property.
Version History
Introduced in R2012aR2022b: Time-domain estimation data is accepted in the form of timetables and matrices
Most estimation, validation, analysis, and utility functions now accept time-domain
input/output data in the form of a single timetable that contains both input and output data
or a pair of matrices that contain the input and output data separately. These functions
continue to accept iddata
objects as a data source as well, for
both time-domain and frequency-domain data.
R2018a: Advanced Options are deprecated for SearchOptions
when SearchMethod
is 'lsqnonlin'
Specification of lsqnonlin
- related advanced options are deprecated,
including the option to invoke parallel processing when estimating using the
lsqnonlin
search method, or solver, in Optimization Toolbox™.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
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
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)