System Identification Analysis
The System Identification Analysis fits a linear time-invariant (LTI) state-space model (blackbox) to measured input-output data.
Transfer functions can be obtained by converting the estimated model using the function tf, and a continuous-time model may be obtained using d2c.
Method Overview
System identification in DyadControlSystems uses two primary methods from ControlSystemIdentification.jl:
Subspace Identification (
subspaceid): A non-iterative method that uses numerical linear algebra to identify state-space models. Fast and reliable for most applications.Prediction Error Method (
newpem): An iterative optimization method that minimizes prediction errors. This method works for closed-loop data and may provide better fit, but takes longer to run.
Both methods identify discrete-time state-space models of the form:
where
Example Definition
The following example demonstrates system identification using measured data from a double-mass model
using DyadControlSystems
using DyadInterface
# Generate simulated data
dmm = DemoSystems.double_mass_model()
Ts = 0.001
f0 = 0.01
f1 = 10
Tf = 30
u = DyadControlSystems.chirp(Ts, f0, f1, Tf; logspace = true, phi=deg2rad(139))'
res = lsim(dmm, u, 0:Ts:Tf, method=:zoh)
# Perform analysis
spec = DyadControlSystems.SystemIdentificationAnalysisSpec(;
input_data = res.u,
output_data = res.y,
Ts,
method = "subspaceid",
nx = 4,
name = :SysID,
detrend = false,
)
sol = DyadInterface.run_analysis(spec)
artifacts(sol, :predplot)artifacts(sol, :bodeplot, lab="Estimated")
bodeplot!(dmm, l=:dash, lab="True")Analysis Arguments
The following arguments define a System Identification Analysis:
Data Input Options
You must provide data using one of these approaches:
Option 1: Direct Arrays
input_data::Real[nu, nT]: Input data matrix where rows are input signals and columns are time pointsoutput_data::Real[ny, nT]: Output data matrix where rows are output signals and columns are time points
Option 2: DyadDataset
dataset: ADyadDatasetobject containing the time series datainput_cols::String[nu]: Names of input signal columns in the datasetoutput_cols::String[ny]: Names of output signal columns in the dataset
Required Parameters
Ts::Real: Sample time of the data (must match actual sampling rate). Only periodic sampled data is supported.
Identification Method Parameters
method::String = "subspaceid": Identification method"subspaceid": Subspace identification (fast and easy)"newpem": Prediction error method (PEM, iterative optimization)
nx::Integer: Model order (state dimension)Set to a positive integer for fixed order
Set to
-1for automatic selection (subspaceid only)
Common Options
simulation_focus::Boolean = false: Optimization focusfalse: Optimize for short-term prediction (default)true: Optimize for open-loop simulation
stable::Boolean = false: Enforce stability of the identified modelzeroD::Boolean = false: Force feedthrough matrixto zero (no direct input-output path) detrend::Boolean = true: Remove mean from data before identification
Method-Specific Parameters
For subspaceid:
r::Integer = 10: Prediction horizon (affects accuracy and computation time)W::String = "MOESP": Weighting method"MOESP": Multivariable Output-Error State Space"CVA": Canonical Variate Analysis"N4SID": Numerical Subspace State Space System Identification"IVM": Instrumental Variable Method
For newpem:
h::Integer = 1: Prediction horizon. Large values may lead to long computational times.
Analysis Parameters
wl::Real = -1: Lower frequency bound for Bode plot (set to -1 for automatic)wu::Real = -1: Upper frequency bound for Bode plot (set to -1 for automatic)num_frequencies::Integer = 3000: Number of frequency points for result analysisduration::Real = -1: Duration for step response in step-response artifact (set to -1 for automatic)
Model Validation
The identified model quality is assessed through the fit metrics and artifacts detailed below:
Fit Percentage
Measures how well the model predictions match the measured output:
where
Artifacts
A SystemIdentificationAnalysis returns the following artifacts:
Plots
:bodeplot: Frequency response of the identified model:stepresponse: Step response showing system dynamics:pzmap: Pole-zero map for stability and dynamics analysis:predplot: Comparison of model predictions vs measured data, uses feedback from measurements (observer):simplot: Comparison of simulated vs measured output, similar to prediction but without measurement feedback:residualplot: Residual correlation analysis for validation
Tables
:modelinfo: DataFrame containing:Model order (nx)
Number of inputs and outputs
Sample time
Fit percentage
Stability status