System identification toolbox matlab documentation

System identification is a methodology for building mathematical models of dynamic systems using measurements of the input and output signals of the system.

The process of system identification requires that you:

Dynamic Systems and Models

In a dynamic system, the values of the output signals depend on both the instantaneous values of the input signals and also on the past behavior of the system. For example, a car seat is a dynamic system—the seat shape (settling position) depends on both the current weight of the passenger (instantaneous value) and how long the passenger has been riding in the car (past behavior).

A model is a mathematical relationship between the input and output variables of the system. Models of dynamic systems are typically described by differential or difference equations, transfer functions, state-space equations, and pole-zero-gain models.

You can represent dynamic models in both continuous-time and discrete-time form.

An often-used example of a dynamic model is the equation of motion of a spring-mass-damper system. As the following figure shows, the mass moves in response to the force F(t) applied on the base to which the mass is attached. The input and output of this system are the force F(t) and displacement y(t), respectively.

Diagram with a force vector and base on the left, spring and damper in the middle, and mass and output vector on the right.

Continuous-Time Dynamic Model Example

You can represent the same physical system as several equivalent models. For example, you can represent the mass-spring-damper system in continuous time as a second-order differential equation:

m d 2 y d t 2 + c d y d t + k y ( t ) = F ( t )

Here, m is the mass, k is the stiffness constant of the spring, and c is the damping coefficient. The solution to this differential equation lets you determine the displacement of the mass y(t), as a function of external force F(t) at any time t for known values of constant m, c, and k.

Consider the displacement y(t) and velocity v ( t ) = d y ( t ) d t as state variables:

x ( t ) = [ y ( t ) v ( t ) ]

You can express the previous equation of motion as a state-space model of the system:

d x d t = A x ( t ) + B F ( t ) y ( t ) = C x ( t )

The matrices A, B, and C are related to the constants m, c, and k as follows:

A = [ 0 1 − k m − c m ] B = [ 0 1 m ] C = [ 1 0 ]

You can also obtain a transfer function model of the spring-mass-damper system by taking the Laplace transform of the differential equation:

G ( s ) = Y ( s ) F ( s ) = 1 ( m s 2 + c s + k )

Here, s is the Laplace variable.

Discrete-Time Dynamic Model Example

Suppose you can observe only the input and output variables F(t) and y(t) of the mass-spring-damper system at discrete time instants t = nTs , where Ts is a fixed time interval and n = 0, 1 , 2, . . The variables are said to be sampled with sample time Ts. Then, you can represent the relationship between the sampled input-output variables as a second-order difference equation, such as

y ( t ) + a 1 y ( t − T s ) + a 2 y ( t − 2 T s ) = b F ( t − T s )

Often, for simplicity, Ts is taken as one time unit, and the equation can be written as

y ( t ) + a 1 y ( t − 1 ) + a 2 y ( t − 2 ) = b F ( t − 1 )

Here, a1 and a2 are the model parameters. The model parameters are related to the system constants m, c, and k, and the sample time Ts.

This difference equation shows the dynamic nature of the model. The displacement value at the time instant t depends not only on the value of force F at a previous time instant, but also on the displacement values at the previous two time instants y(t–1) and y(t–2) .

You can use this equation to compute the displacement at a specific time. The displacement is represented as a weighted sum of the past input and output values:

y ( t ) = b F ( t − 1 ) − a 1 y ( t − 1 ) − a 2 y ( t − 2 )

This equation shows an iterative way of generating values of the output y(t) starting from initial conditions y(0) and y(1) and measurements of input F(t). This computation is called simulation.

Alternatively, the output value at a given time t can be computed using the measured values of output at the previous two time instants and the input value at a previous time instant. This computation is called prediction. For more information on simulation and prediction using a model, see topics on the Simulation and Prediction page.

You can also represent a discrete-time equation of motion in state-space and transfer-function forms by performing the transformations similar to those described in Continuous-Time Dynamic Model Example.

Use Measured Data in System Identification

System identification uses the input and output signals you measure from a system to estimate the values of adjustable parameters in a given model structure. You can build models using time-domain input-output signals, frequency response data, time -series signals, and time-series spectra.

To obtain a good model of your system, you must have measured data that reflects the dynamic behavior of the system. The accuracy of your model depends on the quality of your measurement data, which in turn depends on your experimental design.

Time-Domain Data

Time-domain data consists of the input and output variables of the system that you record at a uniform sampling interval over a period of time.

For example, if you measure the input force F(t) and mass displacement y(t) of the spring-mass-damper system illustrated in Dynamic Systems and Models at a uniform sampling frequency of 10 Hz, you obtain the following vectors of measured values:

u m e a s = [ F ( T s ) , F ( 2 T s ) , F ( 3 T s ) , . , F ( N T s ) ] y m e a s = [ y ( T s ) , y ( 2 T s ) , y ( 3 T s ) , . , y ( N T s ) ]

Here, Ts = 0.1 seconds and NTs is the time of the last measurement.

If you want to build a discrete-time model from this data, the data vectors umeas and ymeas and the sample time Ts provide sufficient information for creating such a model.

If you want to build a continuous-time model, you must also know the intersample behavior of the input signals during the experiment. For example, the input can be piecewise constant (zero-order hold) or piecewise linear (first-order hold) between samples.

Frequency-Domain Data

Frequency-domain data represents measurements of the system input and output variables that you record or store in the frequency domain. The frequency-domain signals are Fourier transforms of the corresponding time-domain signals.

Frequency-domain data can also represent the frequency response of the system, represented by the set of complex response values over a given frequency range. The frequency response describes the outputs to sinusoidal inputs. If the input is a sine wave with frequency ω, then the output is also a sine wave of the same frequency, whose amplitude is A(ω) times the input signal amplitude and a phase shift of Φ(ω) with respect to the input signal. The frequency response is A(ω)e (iΦ(ω)) .

In the case of the mass-spring-damper system, you can obtain the frequency response data by using a sinusoidal input force and measuring the corresponding amplitude gain and phase shift of the response over a range of input frequencies.

You can use frequency-domain data to build both discrete-time and continuous-time models of your system.

Data Quality Requirements

System identification requires that your data capture the important dynamics of your system. Good experimental design ensures that you measure the right variables with sufficient accuracy and duration to capture the dynamics you want to model. In general, your experiment must:

You can analyze the data quality before building the model using the functions and techniques described in Analyze Data. For example, you can analyze the input spectra to determine if the input signals have sufficient power over the bandwidth of the system. To get analysis and processing recommendations for your specific data, use advice .

You can also analyze your data to determine peak frequencies, input delays, important time constants, and indication of nonlinearities using nonparametric analysis tools in this toolbox. You can use this information for configuring model structures for building models from data. For more information, see:

Build Models from Data

Model Structure

A model structure is a mathematical relationship between input and output variables that contains unknown parameters. Examples of model structures are transfer functions with adjustable poles and zeros, state-space equations with unknown system matrices, and nonlinear parameterized functions.

The following difference equation represents a simple model structure:

y ( k ) + a y ( k − 1 ) = b u ( k )

Here, a and b are adjustable parameters.

The system identification process requires that you choose a model structure and apply the estimation methods to determine the numerical values of the model parameters.

You can use one of the following approaches to choose the model structure:

Estimate Model Parameters

The System Identification Toolbox™ software estimates model parameters by minimizing the error between the model output and the measured response. The output ymodel of the linear model is given by

Here, G is the transfer function.

To determine G, the toolbox minimizes the difference between the model output ymodel(t) and the measured output ymeas(t). The minimization criterion is a weighted norm of the error, v(t), where

Accordingly, the error v(t) is called the simulation error or prediction error. The estimation algorithms adjust parameters in the model structure G such that the norm of this error is as small as possible.

Configure Parameter Estimation Algorithm

You can configure the estimation algorithm by:

For more information about configuring the estimation algorithm, see Options to Configure the Loss Function and the topics for estimating specific model structures.

Black-Box Modeling

Select Black-Box Model Structure and Order

Black-box modeling is useful when your primary interest is in fitting the data regardless of a particular mathematical structure of the model. The toolbox provides several linear and nonlinear black-box model structures, which have traditionally been useful for representing dynamic systems. These model structures vary in complexity depending on the flexibility you need to account for the dynamics and noise in your system. You can choose one of these structures and compute its parameters to fit the measured response data.

Black-box modeling is usually a trial-and-error process, where you estimate the parameters of various structures and compare the results. Typically, you start with the simple linear model structure and progress to more complex structures. You might also choose a model structure because you are more familiar with this structure or because you have specific application needs.

The simplest linear black-box structures require the fewest options to configure:

Estimation of some of these structures also uses noniterative estimation algorithms, which further reduces complexity.

You can configure a model structure using the model order. The definition of model order varies depending on the type of model you select. For example, if you choose a transfer function representation, the model order is related to the number of poles and zeros. For state-space representation, the model order corresponds to the number of states. In some cases, such as for linear ARX and state-space model structures, you can estimate the model order from the data.

If the simple model structures do not produce good models, you can select more complex model structures by:

Ultimately, you choose the simplest model structure that provides the best fit to your measured data. For more information, see Estimating Linear Models Using Quick Start.

Regardless of the structure you choose for estimation, you can simplify the model for your application needs. For example, you can separate out the measured dynamics (G) from the noise dynamics (H) to obtain a simpler model that represents just the relationship between y and u. You can also linearize a nonlinear model about an operating point.

Use Nonlinear Model Structures

A linear model is often sufficient to accurately describe the system dynamics and, in most cases, a best practice is to first try to fit linear models. If the linear model output does not adequately reproduce the measured output, you might need to use a nonlinear model.

You can assess the need to use a nonlinear model structure by plotting the response of the system to an input. If you notice that the responses differ depending on the input level or input sign, try using a nonlinear model. For example, if the output response to an input step up is faster than the response to a step down, you might need a nonlinear model.

Before building a nonlinear model of a system that you know is nonlinear, try transforming the input and output variables such that the relationship between the transformed variables is linear. For example, consider a system that has current and voltage as inputs to an immersion heater, and the temperature of the heated liquid as an output. The output depends on the inputs through the power of the heater, which is equal to the product of current and voltage. Instead of building a nonlinear model for this two-input and one-output system, you can create a new input variable by taking the product of the current and voltage and building a linear model that describes the relationship between power and temperature.

If you cannot determine variable transformations that yield a linear relationship between input and output variables, you can use nonlinear structures such as nonlinear ARX or Hammerstein-Wiener models. For a list of supported nonlinear model structures and when to use them, see Nonlinear Model Structures.

Black-Box Estimation Example

You can use the System Identification app or commands to estimate linear and nonlinear models of various structures. In most cases, you choose a model structure and estimate the model parameters using a single command.

Consider the mass-spring-damper system described in Dynamic Systems and Models. If you do not know the equation of motion of this system, you can use a black-box modeling approach to build a model. For example, you can estimate transfer functions or state-space models by specifying the orders of these model structures.

A transfer function is a ratio of polynomials:

G ( s ) = ( b 0 + b 1 s + b 2 s 2 + . ) ( 1 + f 1 s + f 2 s 2 + . )

For the mass-spring damper system, this transfer function is

G ( s ) = 1 ( m s 2 + c s + k )

which is a system with no zeros and 2 poles.

In discrete-time, the transfer function of the mass-spring-damper system can be

G ( z − 1 ) = b z − 1 ( 1 + f 1 z − 1 + f 2 z − 2 )

where the model orders correspond to the number of coefficients of the numerator and the denominator ( nb = 1 and nf = 2) and the input-output delay equals the lowest order exponent of z –1 in the numerator ( nk = 1).

In continuous time, you can build a linear transfer function model using the tfest command.

m = tfest(data,2,0)

Here, data is your measured input-output data, represented as an iddata object, and the model order is the set of number of poles (2) and the number of zeros (0).

Similarly, you can build a discrete-time model Output Error structure using the oe command.

m = oe(data,[1 2 1])

The model order is [ nb nf nk ] = [ 1 2 1 ]. Usually, you do not know the model orders in advance. Try several model order values until you find the orders that produce an acceptable model.

Alternatively, you can choose a state-space structure to represent the mass-spring-damper system and estimate the model parameters using the ssest or the n4sid command.

m = ssest(data,2)

Here, the second argument 2 represents the order, or the number of states in the model.

In black-box modeling, you do not need the equation of motion for the system — only a guess of the model orders.

Grey-Box Modeling

In some situations, you can deduce the model structure from physical principles. For example, the mathematical relationship between the input force and the resulting mass displacement in the spring-mass-damper system illustrated in Dynamic Systems and Models is well known. In state-space form, the model is given by

d x d t = A x ( t ) + B F ( t ) y ( t ) = C x ( t )

where x ( t ) = [ y ( t ); v ( t )] is the state vector. The coefficients A, B, and C are functions of the model parameters:

Here, you fully know the model structure but do not know the values of its parameters—m, c, and k.

In the grey-box approach, you use the data to estimate the values of the unknown parameters of your model structure. You specify the model structure by a set of differential or difference equations in MATLAB and provide some initial guess for the unknown parameters specified.

In general, you build grey-box models by:

  1. Creating a template model structure.
  2. Configuring the model parameters with initial values and constraints (if any).
  3. Applying an estimation method to the model structure and computing the model parameter values.

The following table summarizes the ways you can specify a grey-box model structure.

Represent the state-space model structure as a structured idss model object and estimate the state-space matrices A, B, and C.

You can compute the parameter values, such as m, c, and k, from the state space matrices A and B. For example, m = 1/B(2) and k = –A(2,1)m.

Evaluate Model Quality

After you estimate the model, you can evaluate the model quality by:

Ultimately, you must assess the quality of your model based on whether the model adequately addresses the needs of your application. For information about other available model analysis techniques, see Model Analysis.

If you do not get a satisfactory model, you can iteratively improve your results by trying a different model structure, changing the estimation algorithm settings, or performing additional data processing. If these changes do not improve your results, you might need to revisit your experimental design and data gathering procedures.

Compare Model Response to Measured Response

Typically, you evaluate the quality of a model by comparing the model response to the measured output for the same input signal.

Suppose you use a black-box modeling approach to create dynamic models of the spring-mass damper system. You try various model structures and orders, such as:

model1 = arx(data, [2 1 1]); model2 = n4sid(data, 3)

You can simulate these models with a particular input and compare their responses against the measured values of the displacement for the same input applied to the real system. The following figure compares the simulated and measured responses for a step input.

The figure indicates that model2 is better than model1 because model2 better fits the data (65% vs. 83%).

The fit percentage indicates the agreement between the model response and the measured output: 100 means a perfect fit, and 0 indicates a poor fit (that is, the model output has the same fit to the measured output as the mean of the measured output).

For more information, see topics on the Compare Output with Measured Data page.

Analyze Residuals

The System Identification Toolbox software lets you perform residual analysis to assess the model quality. Residuals represent the portion of the output data not explained by the estimated model. A good model has residuals uncorrelated with past inputs.

For more information, see the topics on the Residual Analysis page.

Analyze Model Uncertainty

When you estimate the model parameters from data, you obtain their nominal values that are accurate within a confidence region. The size of this region is determined by the values of the parameter uncertainties computed during estimation. The magnitude of the uncertainties provide a measure of the reliability of the model. Large uncertainties in parameters can result from unnecessarily high model orders, inadequate excitation levels in the input data, and a poor signal-to-noise ratio in measured data.

You can compute and visualize the effect of parameter uncertainties on the model response in the time and frequency domains using pole-zero maps, Bode response plots, and step response plots. For example, in the following Bode plot of an estimated model, the shaded regions represent the uncertainty in amplitude and phase of the frequency response of the model, computed using the uncertainty in the parameters. The plot shows that the uncertainty is low only in the 5 to 50 rad/s frequency range, which indicates that the model is reliable only in this frequency range.

Resources

The System Identification Toolbox documentation provides you with the necessary information to use this product. Additional resources are available to help you learn more about specific aspects of system identification theory and applications.

The following book describes methods for system identification and physical modeling:

These books provide detailed information about system identification theory and algorithms:

For information about working with frequency-domain data, see the following book:

For information on nonlinear identification, see the following references:

For more information about systems and signals, see the following book:

The following textbook describes numerical techniques for parameter estimation using criterion minimization:

Related Topics