Skip to content

Latest commit

 

History

History
325 lines (245 loc) · 12.8 KB

File metadata and controls

325 lines (245 loc) · 12.8 KB

MATLAB Simulink 30 Tutorials MIT Bilingual Stars Last Commit CI

Simulink Control Engineering Tutorial

From Zero to Embedded Code Deployment — 25 Hands-On Lessons
Classical, Modern, Robust, Nonlinear, MPC, Adaptive, Fuzzy, Physical Modeling, and Code Generation

中文版请见 README.md


Table of Contents


Preview

All figures auto-generated by run_all_tutorials. See docs/images for the full set.

PID Control (t05) LQR Optimal Control (t10)
PID LQR
Kalman Filter (t12) PMSM FOC (t14)
Kalman FOC

Quick Start

Step 1: Clone

git clone https://github.com/xingd5478-ctrl/simulink-control-tutorial.git

Step 2: Check your environment

In MATLAB, navigate to the project folder and run:

>> check_setup

Step 3: Start learning

>> t00_main_guide            % Course overview (25 lessons)
>> t01_signal_basics         % Lesson 1: Sine wave + Gain + Scope

Step 4: Follow the learning path

% Phase 1 (t01-t08) — Simulink fundamentals, no extra toolboxes needed
% Phase 2 (t16, t17, t22) — Classical control design
% Phase 3 (t09-t12) — Modern control theory
% Phase 4 (t18-t21, t23, t24) — Advanced control topics
% Phase 5 (t13, t14, t25, t15) — Applications & deployment

% Or run everything at once:
>> run_all_tutorials

Each script auto-creates a Simulink model (.slx) → configures blocks → runs simulation → generates result plots. No manual model-building required.

After each lesson

  1. Double-click the Scope block — view the waveform
  2. Double-click other blocks — see how parameters are set
  3. Tweak a parameter — change Gain from 2 to 5, re-run, observe the change
  4. Look at the MATLAB Figure — comparison plots help you understand concepts

Prerequisites

Dependency Notes Phase
MATLAB R2020a+ Core runtime All
Simulink Model building and simulation All
Control System Toolbox State-space, LQR, Kalman, freq analysis Phase 2-5
Robust Control Toolbox H∞ / μ analysis t19 (optional)
Model Predictive Control Toolbox MPC design t20 (optional)
Fuzzy Logic Toolbox Fuzzy inference system t24 (optional)
Simscape Physical modeling t25 (optional)

Beginner tip: t01-t08 need only MATLAB + Simulink. Run check_setup to verify your environment.


FAQ

Q: I have zero control theory background. Can I follow?

Yes. Phase 1 (t01-t08) teaches only Simulink operations, no control theory. Later lessons explain control concepts as needed.

Q: "Undefined function or variable" error?

Make sure MATLAB's Current Folder is the project root (simulink-control-tutorial/). Use the folder panel in MATLAB to navigate there.

Q: No waveform in Scope?

Double-click the Scope block. If the line is flat, check the Step block's Step time parameter — it jumps at 0.5s, not 0s.

Q: Too many model windows open?
>> bdclose all     % Close all Simulink models
>> close all       % Close all Figures
Q: How do I regenerate a tutorial model?

Simply re-run the script — it overwrites the old .slx:

>> t05_pid_control

Tutorial Overview

25 lessons, 5 phases — progressive learning path from fundamentals to industrial applications.

Phase 1 — Simulink Fundamentals (t01-t08)

# Tutorial Content Model
t01 Signal Basics Signals, gain blocks, scopes
t02 Math Operations Sum, product, Mux/Demux routing
t03 First-Order Systems Transfer functions, time constants
t04 Second-Order Systems Damping ratio, overshoot, natural frequency
t05 PID Control P/I/D effects, feedback loop tuning
t06 Sources & Sinks Data import/export, signal generators
t07 Subsystems Hierarchical model packaging
t08 Masking Parameterized block design

Phase 2 — Classical Control Design (t16, t17, t22)

# Tutorial Core Theory Engineering Value
t16 Frequency Domain Bode, Nyquist, Nichols, gain/phase margin Stability analysis
t17 Lead-Lag Compensator Lead/Lag compensation, frequency shaping Classical control design
t22 Root Locus rlocus(), pole trajectories, compensator design Classical design visualization

Phase 3 — Modern Control Theory (t09-t12)

# Tutorial Core Theory Engineering Value
t09 State-Space Models ẋ=Ax+Bu, y=Cx+Du Modern control foundation
t10 LQR Optimal Control Pole placement, Riccati equation, Q/R tuning MIMO system design
t11 State Observer Luenberger Observer, duality, (A-LC) Sensorless control
t12 Kalman Filter lqe(), Q/R noise modeling, Luenberger comparison Optimal estimation under noise

Phase 4 — Advanced Control Topics (t18-t21, t23, t24)

# Tutorial Core Theory Engineering Value
t18 System Identification Step response, least-squares, model validation From data to transfer function
t19 H∞ Robust Control Mixed sensitivity, hinfsyn, μ analysis Optimal control under uncertainty
t20 MPC Receding horizon, QP constraints, explicit MPC Constrained multivariable control
t21 Sliding Mode Control Sliding surface, chattering suppression, STSMC Nonlinear robust control
t23 MRAC Adaptive Control MIT rule, reference model, parameter adaptation Online tuning for time-varying systems
t24 Fuzzy Logic Control Sugeno FIS, membership functions, control surface Model-free expert knowledge control

Phase 5 — Applications & Deployment (t13, t14, t25, t15)

# Tutorial Core Theory Engineering Value
t13 DC Motor Control Electromagnetic + mechanical coupling, cascaded PI, LQR Actuator modeling
t14 PMSM + FOC d-q transform, Clarke/Park, vector control Brushless motor control
t25 Simscape Physical Modeling Physical components, multi-domain, auto-derived equations Formula-free modeling approach
t15 Code Generation c2d discretization, dlqr, C code, FreeRTOS Embedded deployment

Learning Path

Phase 1 (Basics)    Phase 2 (Classical)  Phase 3 (Modern)    Phase 4 (Advanced)   Phase 5 (Apps)
                                                                                
t01-t08 Basics ──→ t16 Freq Domain ──→ t09 State-Space ──→ t18 System ID ──→ t13 DC Motor
                     │                   │                   │                  │
                     ├── t17 Lead-Lag    ├── t10 LQR         ├── t19 H∞       ├── t14 FOC
                     │                   │                   │                  │
                     └── t22 Root Locus  ├── t11 Observer    ├── t20 MPC      ├── t25 Simscape
                                         │                   │                  │
                                         └── t12 Kalman      ├── t21 SMC       └── t15 Code Gen
                                                             │
                                                             ├── t23 MRAC
                                                             │
                                                             └── t24 Fuzzy

What You'll Learn

After completing all 25 lessons, you will be able to:

  • Derive state-space models from physical laws
  • Design LQR/Kalman optimal controllers and observers
  • Analyze stability in the frequency domain (Bode/Nyquist) and design compensators
  • Identify system models from experimental data
  • Handle parameter uncertainty with H∞ robust control
  • Design MPC controllers for constrained systems
  • Implement sliding mode control for nonlinear/high-disturbance systems
  • Analyze pole trajectories with root locus and design compensators
  • Design MRAC adaptive controllers for time-varying systems
  • Build fuzzy logic control systems without precise mathematical models
  • Model physical systems in Simscape without deriving equations
  • Go from continuous → discrete → C code, deploy to STM32 and other embedded platforms
  • Understand cascaded PI and FOC vector control in industrial practice

Project Structure

.
├── check_setup.m                 # Environment checker (run this first)
├── t00_main_guide.m              # Tutorial index
├── t01-t25_*.m                   # 25 tutorial scripts
├── models/                       # Simulink models (auto-generated)
│   └── tutorial01-tutorial25.slx
├── utils/                        # Shared utilities
│   └── getSimData.m
├── run_all_tutorials.m           # Batch runner for all tutorials
├── docs/images/                  # Auto-generated simulation figures
├── .github/                      # Issue/PR templates
├── README.md                     # 中文版
├── README_EN.md                  # This file (English)
├── CHANGELOG.md                  # Changelog
├── CONTRIBUTING.md               # Contribution guide
├── CODE_OF_CONDUCT.md            # Code of conduct
├── SECURITY.md                   # Security policy
└── LICENSE                       # MIT

Companion Projects


Contributing

Issues and PRs are welcome! Bug reports, new tutorial ideas, and documentation improvements all count.

See CONTRIBUTING.md for details.

Star History

Star History Chart

License

MIT — Free to use, modify, and distribute. See LICENSE.

If this tutorial helps you, a ⭐ Star would be greatly appreciated!


Xing Dong · 2026