Back to Browse

Linear Model Predictive Control in MATLAB - Part 1

737 views
Oct 30, 2025
17:30

Linear Model Predictive Control in MATLAB - Part 1 Here's a ๐—ฃ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐—ป๐˜๐—ฟ๐—ผ๐—น example: โœ… ๐—ฃ๐—น๐—ฎ๐—ป๐˜ An object of mass m = 10 kg, sliding on a surface, subject to a damping coefficient k = 0.5 N*s/m, pushed by a force F. The dynamic equation is: ๐Ÿ‘‰ z'' m = F - k z' Using MPC, we want to control the object's position via the force input. Note that the system is linear. โœ… ๐—ฃ๐—น๐—ฎ๐—ป๐˜ ๐— ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ถ๐—ป ๐— ๐—”๐—ง๐—Ÿ๐—”๐—• ๐—ณ๐—ผ๐—ฟ ๐— ๐—ฃ๐—– To implement linear MPC in MATLAB/Simulink we need to create a linear MPC object (mpc) in MATLAB and give it our dynamic system. The system is of the type: ๐Ÿ‘‰ x' = Ax + Bu ๐Ÿ‘‰ y = Cx + Du where u = F and x = [z' z]. ๐Ÿ‘‰ A = [-k/m 0; 1 0] ๐Ÿ‘‰ B = [1/m; 0] ๐Ÿ‘‰ C = [0 1] ๐Ÿ‘‰ D = 0 Note that we only measure the position z, not z', as C = [0 1]. โœ… ๐—ง๐˜‚๐—ป๐—ถ๐—ป๐—ด Scaling factors: ๐Ÿ‘‰ Output variable: 2 ๐Ÿ‘‰ Manipulated Variable: 10 Weights: ๐Ÿ‘‰ Output variable: 1 ๐Ÿ‘‰ Manipulated Variable: 0 ๐Ÿ‘‰ Manipulated Variable Rate of Change: 0.1 Constraints: ๐Ÿ‘‰ Output variable: [-2, 2] m ๐Ÿ‘‰ Manipulated Variable: [-10, 10] N MPC parameters: ๐Ÿ‘‰ Sample time: 0.1 s ๐Ÿ‘‰ Prediction horizon: 10 ๐Ÿ‘‰ Control horizon: 2 โœ… ๐—ฆ๐—ถ๐—บ๐˜‚๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฅ๐—ฒ๐˜€๐˜‚๐—น๐˜ The simulation is performed directly in MATLAB using the command ๐˜€๐—ถ๐—บ, for 5 seconds, on the nominal system. The Model Predictive Control algorithm is controlling smoothly and with minimum overshoot. Note that the model used for the algorithm is the same as the model used for the validation, which is not a realistic scenario, and the result is expected to be very good. The next steps will be: ๐Ÿ‘‰ Disturbance rejection ๐Ÿ‘‰ Test for robustness ๐Ÿ‘‰ What else would you like to see? Let me know in the comments! ------------------- โœ… Know someone who could benefit from this? Tag them in the comments! โœ… Do you like this content? Subscribe! โœ… Do you want more? Follow me on LinkedIn https://www.linkedin.com/in/simone-bertoni-control-eng or visit my website https://simonebertonilab.com/ #controlsystems #matlab #simulink #controltheory #mpc

Download

0 formats

No download links available.

Linear Model Predictive Control in MATLAB - Part 1 | NatokHD