MATLAB codes for system identification — from classical methods to multirate and periodically time-varying systems.
This repository accompanies the blog hub article:
System Identification: From Data to Dynamical Models — A Comprehensive Guide
Each folder contains MATLAB scripts with explanatory comments. The codes are designed to be self-contained and educational — run them directly in MATLAB to reproduce the results discussed in the corresponding blog articles and papers.
| Folder | Topic | Blog Article | Paper |
|---|---|---|---|
01_basic_sysid/ |
Introduction to system identification | System Identification: Obtaining Dynamical Model | — (educational) |
02_subspace_n4sid/ |
Subspace identification: N4SID, MOESP, CVA | Subspace System Identification: N4SID, MOESP, and CVA | — (educational) |
03_lptv_cyclic_sysid/ |
Cyclic reformulation for LPTV systems | Cyclic Reformulation-Based System Identification for LPTV Systems | IEEE Access 2025 |
04_multirate_sysid/ |
Multirate system identification | System Identification Under Multirate Sensing Environments | JRM 2025 (Open Access) |
05_parametric_pem/ |
ARX, ARMAX, OE, BJ, and the prediction error method | Classical Parametric System Identification: ARX, ARMAX, and the PEM | — (educational) |
06_kernel_based/ |
Kernel-based regularized impulse response estimation | Kernel-Based System Identification | — (educational) |
- MATLAB R2020b or later
- System Identification Toolbox (for
n4sid,arx,armax,pem,ssest,impulseest) - Control System Toolbox (for
tf,ss,bode,balred) - Robust Control Toolbox (for LMI-related examples in
03_lptv_cyclic_sysid/)
% Clone the repository
% >> git clone https://github.com/Hiroshi-Okajima/MATLAB_system_identification.git
% Navigate to a folder and run the main script
cd 01_basic_sysid
run('basic_sysid_demo.m')Each folder contains a main script (named *_demo.m or main_*.m) that reproduces the key results.
A simple educational example demonstrating the basic workflow of system identification: data generation → model estimation → validation. Uses a 2nd-order discrete-time system.
What you will learn:
- How to create
iddataobjects in MATLAB - Basic ARX estimation with
arx - Model validation with
compareandresid
Demonstrates the three major subspace identification algorithms (N4SID, MOESP, CVA) on the same dataset, comparing their results. Includes model order selection via singular value analysis.
What you will learn:
- Using
n4sidwith different weighting options ('auto','MOESP','CVA') - Model order selection from singular value plots
- Combining
n4sidwithpemrefinement viassest - Comparison table of identified models
Reproduces the numerical example from the IEEE Access 2025 paper. Identifies a periodically time-varying (LPTV) system using cyclic reformulation and subspace identification.
What you will learn:
- Construction of cycled signals from LPTV data
- Subspace identification (N4SID) of the cycled LTI system
- State coordinate transformation to recover LPTV parameters
- Verification that the identified parameters match the true system
Paper: H. Okajima, Y. Fujimoto, H. Oku and H. Kondo, Cyclic Reformulation-Based System Identification for Periodically Time-Varying Systems, IEEE Access, 2025.
Reproduces the numerical example from the JRM 2025 paper. Identifies a discrete-time LTI plant from multirate sensor data (different output sampling rates).
What you will learn:
- Multirate system formulation with periodic observation matrices
- Construction of cycled signals for multirate data
- The complete 4-step identification algorithm (Algorithm 1 in the paper)
- Transfer function recovery and comparison with the true plant
Paper: H. Okajima, R. Furukawa and N. Matsunaga, System Identification Under Multirate Sensing Environments, Journal of Robotics and Mechatronics, Vol. 37, No. 5, pp. 1102–1112, 2025. (Open Access)
See also: Code Ocean capsule for the original reproducible code.
Demonstrates the four classical parametric model structures (ARX, ARMAX, Output-Error, Box-Jenkins) and the prediction error method (PEM) on a common example. Includes model order selection via AIC/BIC and comparison with subspace identification.
What you will learn:
- Estimating ARX, ARMAX, OE, and BJ models in MATLAB
- Using
pemandssestfor PEM-based estimation - Model order selection with
arxstruc,selstruc, AIC, BIC - Residual analysis with
resid - Comparison between parametric and subspace approaches
Demonstrates kernel-based regularized impulse response estimation using impulseest with TC, SS, and DC kernels. Compares with unregularized (ordinary least squares) FIR and parametric ARX. Includes visualization of kernel matrices and the effect of data length on estimation quality.
What you will learn:
- Using
impulseestwith different regularization kernels ('TC','SS','DC','none') - How kernel matrices encode prior knowledge (exponential decay, smoothness)
- Why regularization helps with short data and low SNR
- Converting regularized FIR models to state-space via
balred - Comparison between kernel-based and parametric (ARX) approaches
- Hub: System Identification: From Data to Dynamical Models
- System Identification: Obtaining Dynamical Model
- Subspace System Identification: N4SID, MOESP, and CVA
- Classical Parametric System Identification: ARX, ARMAX, and the PEM
- Kernel-Based System Identification: Regularized Impulse Response Estimation
- Cyclic Reformulation-Based System Identification for LPTV Systems
- System Identification Under Multirate Sensing Environments
- State Observer and State Estimation
- Model Error Compensator (MEC)
- LMIs and Controller Design
- Discretization of Continuous-Time Control Systems
- MATLAB_state_observer — State observer and estimation codes (observer design uses identified models)
- MATLAB_fandamental_control_LMI — LMI-based control design
- Robust-control-MATLAB_MEC01 — Model Error Compensator
Hiroshi Okajima — Associate Professor, Graduate School of Science and Technology, Kumamoto University, Japan. Member of SICE, ISCIE, and IEEE.
This project is licensed under the MIT License — see the LICENSE file for details.