Skip to content

Hiroshi-Okajima/MATLAB_system_identification

Repository files navigation

MATLAB_system_identification

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.


Repository Structure

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)

Quick Start

Requirements

  • 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/)

Running the Examples

% 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.


Folder Details

01_basic_sysid — Introduction to System Identification

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 iddata objects in MATLAB
  • Basic ARX estimation with arx
  • Model validation with compare and resid

02_subspace_n4sid — Subspace Identification Methods

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 n4sid with different weighting options ('auto', 'MOESP', 'CVA')
  • Model order selection from singular value plots
  • Combining n4sid with pem refinement via ssest
  • Comparison table of identified models

03_lptv_cyclic_sysid — Cyclic Reformulation for LPTV Systems

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.

04_multirate_sysid — Multirate System Identification

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.

05_parametric_pem — Classical Parametric Methods and PEM

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 pem and ssest for PEM-based estimation
  • Model order selection with arxstruc, selstruc, AIC, BIC
  • Residual analysis with resid
  • Comparison between parametric and subspace approaches

06_kernel_based — Kernel-Based Regularized System Identification

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 impulseest with 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

Related Resources

Blog Articles

Research Web Pages

Video

MATLAB File Exchange / Code Ocean

Other GitHub Repositories


Author

Hiroshi Okajima — Associate Professor, Graduate School of Science and Technology, Kumamoto University, Japan. Member of SICE, ISCIE, and IEEE.


License

This project is licensed under the MIT License — see the LICENSE file for details.