Home » Practical Model Predictive Control Course

Practical Model Predictive Control Course

A Linear and Nonlinear MPC Journey From Simulation to C Code Generation Using MATLAB®/Simulink® and Python


Linear and Nonlinear MPC in Practice

Most Model Predictive Control courses stop at theory. This one DOESN’T.

You’ll go from first principles to running C code.

In this course, you will:

  • Design MPC controllers from first principles
  • Tune and validate both linear and nonlinear MPC controllers
  • Build a linear MPC controller for a DC motor
  • Develop a nonlinear MPC controller for hovercraft trajectory tracking
  • Implement every controller twice: once in MATLAB/Simulink and once in Python (acados)
  • Generate the C code for each control system and run it in simulation

All the code is provided!

Practical Model Predictive Control: Course Overview


Not convinced?

Try the following free lessons first

No sign-up required. Just dive in.

Model Predictive Control Theory

2.1 – Intro – Architecture – Linear and Nonlinear Prediction Model

MATLAB/Simulink – Linear MPC (DC Motor)

4.3 – DC Motor in Simscape

Python – Linear MPC (DC Motor)

7.7 – First run


What you’ll learn

This is an intermediate-to-advanced course. What you’ll gain here is everything between “I know what MPC is” and “I can deploy my controller on hardware.”

Linear MPC – DC Motor (MATLAB/Simulink and Python/acados)

Start with a classic SISO system: a DC motor. You’ll model it, design an MPC controller around it, and systematically explore every tuning lever – prediction horizon, control horizon, sample time, weights, hard constraints, soft constraints, and measured and unmeasured disturbance rejection. You’ll also design a discrete Kalman Filter for state estimation and study its gain convergence.

This topic is covered in both MATLAB/Simulink and Python (using acados on Ubuntu/WSL), so you see exactly how the same problem is approached in each environment.

Nonlinear MPC – Hovercraft Trajectory Following (MATLAB/Simulink and Python/acados)

The nonlinear section is where this course separates itself from everything else available. You’ll build a MIMO nonlinear MPC controller for a hovercraft – a 2-thruster and 3-thruster configuration – doing full trajectory following with obstacle avoidance.
You’ll design an Extended Kalman Filter (EKF) for state estimation, implement trajectory preview functions, and simulate the complete closed-loop system. Again: done twice – once in MATLAB/Simulink, once in Python with acados.

C Code Generation and Simulation

Every controller designed in the course ends with C code generation. From MATLAB Coder / Simulink Embedded Coder on the MATLAB side, and from acados’s native C code output on the Python side, you’ll run the generated code inside a simulator and verify results. This is the bridge between algorithm and deployment.

Course curriculum

  • Chapter 1 – Introduction: What the course covers, tools required, and how to get the most from it.
  • Chapter 2 – Model Predictive Control Theory: What MPC is, the receding-horizon architecture, linear vs nonlinear prediction models, cost functions, constraints, and state estimation with Kalman and Extended Kalman Filters.
  • Chapter 3 – Overview of What’s Ahead: A guided map of the practical sections so you know what to watch depending on your focus (MATLAB, Python, or both).
  • Chapter 4 – MATLAB/Simulink: Linear MPC (DC Motor): 19 lessons. DC motor model in Simscape, MPC object design, constraints, soft constraints, cost and status, horizons, sample time, weights, robustness, Kalman Filter, disturbance rejection (measured and unmeasured), time delay, online weight changes, constraint on current, setpoint preview, and C code generation.
  • Chapter 5 – MATLAB/Simulink: Nonlinear MPC (Hovercraft): 22 lessons. 2-thruster and 3-thruster hovercraft models in Simscape, nonlinear MPC design, EKF implementation, trajectory generation, trajectory preview, simulation results, and C code generation with a full C simulation of the closed-loop system.
  • Chapter 6 – Python Setup: acados and Ubuntu (WSL): Installing WSL and Ubuntu on Windows, building acados from source, setting up the Python virtual environment and acados Python interface. Step-by-step. Everything is free and open source.
  • Chapter 7 – Python: Linear MPC (DC Motor): 21 lessons. DC motor ODE model, discrete model for MPC, Kalman Filter with gain convergence analysis, acados solver setup, Python simulation architecture, and the same systematic tuning sequence as Chapter 4 – then C code generation via acados.
  • Chapter 8 – Python: Nonlinear MPC (Hovercraft): 12 lessons. Hovercraft ODE and discrete models, EKF in Python, acados solver functions for nonlinear problems, trajectory preview, simulation and results, and C code generation with results.

What is Model Predictive Control – and why should you consider this course?

Model Predictive Control (MPC) is an advanced control strategy in industry. At every sampling interval, an MPC controller solves an optimisation problem over a future prediction horizon, respects hard and soft constraints on inputs and outputs, and applies only the first computed move before repeating the process.

It can be used everywhere: automotive systems, aerospace, robotics, energy grids, and chemical processes.

The challenge? Designing MPC that actually works in deployment – handling nonlinear dynamics, state estimation, constraint tuning, and real-time computation – requires going well beyond textbook equations.

That’s what this course teaches.

Who this Model Predictive Control course is for

This course is designed for people who already know what a control system is and want to go deeper into predictive control – with real code and real examples.

It suits: control engineers wanting to add MPC to their toolkit; mechanical, electrical, and aerospace engineers working on motion control, robotics, or embedded systems; researchers and PhD students who want to implement MPC in Python or MATLAB rather than simulate it in papers; and computer science professionals working with of optimisation and control.

You do not need prior MPC experience. You do need to be comfortable with linear algebra, basic state-space control, and either MATLAB or Python.

Tools and software

MATLAB side: MATLAB, Simulink, Simscape, Simscape Multibody, Control System Toolbox, Model Predictive Control Toolbox, Optimization Toolbox, MATLAB Coder, and Embedded Coder. A trial licence includes all toolboxes except for Embedded Coder, which is only used for the code generation.

Python side: Everything is free and open source. Ubuntu (via WSL on Windows), Python 3, acados (built from source), CasADi, and the acados Python interface. Full installation covered step by step in Chapter 6.


Course Content

1 – Introduction

2 – Model Predictive Control Theory

2.2 – Cost function – Constraints – Example


3 – Overview of What's ahead

3.1 – Overview of What’s ahead


Resources

Resources


4 – MATLAB/Simulink: Linear MPC (DC Motor)

4.1 – DC Motor Model


4.2 – Create DC motor and MPC object in MATLAB


4.4 – Simulink implementation and first run


4.5 – Constraints


4.6 – Soft constraints


4.7 – Cost and status


4.8 – Horizons


4.9 – Sample time


4.10 – Weights


4.11 – Robustness


4.12 – Kalman Filter


4.13 – Measured disturbance rejection


4.14 – Unmeasured disturbance rejection


4.15 – Time delay


4.16 – Changing weights online


4.17 – Constraint on current


4.18 – Setpoint preview


4.19 – Code generation


5 – MATLAB/Simulink: Nonlinear MPC (Hovercraft)

5.1 – Hovercraft model – 2 or 3 Thrusters


5.2 – Hovercraft 2T – Simscape


5.3 – Hovercraft 2T – Control system architecture in Simulink


5.4 – Hovercraft 2T – State function and output function


5.5 – Obstacle


5.6 – Hovercraft 2T – Nonlinear MPC design


5.7 – Hovercraft 2T – Extended Kalman Filter


5.8 – Trajectory generation


5.9 – Trajectory preview function


5.10 – Hovercraft 2T – Simulation result


5.11 – Hovercraft 3T – Simscape


5.12 – Hovercraft 3T – Control system architecture in Simulink


5.13 – Hovercraft 3T – State function and output function


5.14 – Hovercraft 3T – Nonlinear MPC design


5.15 – Hovercraft 3T – Extended Kalman Filter


5.16 – Hovercraft 3T – Simulation result


5.17 – Hovercraft 2T – Code generation


5.18 – C code – Hovercraft 2T – Architecture


5.19 – C code – Hovercraft 2T – Model


5.20 – C code – Hovercraft 2T – Extended Kalman Filter


5.21 – C code – Trajectory preview


5.22 – C code – Simulation result


6 – Python Setup: Acados and Ubuntu (WSL)

6.1 – Install WSL and Ubuntu


6.2 – Install Acados


6.3 – Install Acados Python Interface





1 of 2

Want to know more about me?

Check out my profile and content on LinkedIn and YouTube:

Simone Bertoni – LinkedIn

Simone Bertoni – Control Lab – YouTube

and see if you like the topics I discuss!

FAQ – Frequently Asked Questions

Do I need both MATLAB and Python?

No. The course is structured so the MATLAB and Python sections are self-contained. You can follow only the Python path (Chapters 2, 3, 6, 7, 8) at zero cost. Watch Chapter 4 and 5 regardless – they contain important MPC design discussions not repeated elsewhere.

Do I need prior MPC experience?

No. Chapter 2 covers the necessary theory to follow the course from scratch, however, deep theorectical knowledge is not covered (that kind of knowledge is better studied in a book). Prior experience with state-space models and control system basics is assumed.

Is Python free to use for this course?

Everything on the Python side – Ubuntu, acados, CasADi, the Python interface – is free and open source. Chapter 6 walks through installation from zero.

What is acados?

Acados is a high-performance, open-source software package for solving nonlinear optimal control problems. Written in C with Python, MATLAB, and Octave interfaces, it’s designed for real-time embedded applications and is used in robotics, automotive systems, and aerospace research worldwide.

Can I generate C code from this course?

Yes. Both the MATLAB and Python sections end with C code generation and verify the results in a C simulator. This is a core part of the course, not an optional add-on.

What physical examples does the course use?

A DC motor (linear SISO MPC) and a hovercraft in 2-thruster and 3-thruster configurations (nonlinear MIMO MPC with trajectory following and obstacle avoidance).

Scroll to Top
Menu