Back to Browse

Linear Model Predictive Control in MATLAB - Part 3 (Constraints on Controlled Variable)

46 views
Feb 21, 2026
7:39

๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—ณ๐—ฎ๐˜ƒ๐—ผ๐˜‚๐—ฟ๐—ถ๐˜๐—ฒ ๐—ณ๐—ฒ๐—ฎ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ถ๐—ป ๐— ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ฃ๐—ฟ๐—ฒ๐—ฑ๐—ถ๐—ฐ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—–๐—ผ๐—ป๐˜๐—ฟ๐—ผ๐—น? Constraints are a big one. Let's recap what was in the last post. โœ… ๐—ฃ๐—น๐—ฎ๐—ป๐˜ 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 Constraints: ๐Ÿ‘‰ Manipulated variable: [-10, 10] N MPC parameters: ๐Ÿ‘‰ Sample time: 0.1 s ๐Ÿ‘‰ Prediction horizon: 10 ๐Ÿ‘‰ Control horizon: 2 โœ… ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜€๐—ถ๐˜€ For this analysis, we want to test the effect of constraints on the controlled variable (the position). To make the effect more visible, the MPC controller has been modified to be more aggressive (weight on the manipulated variable rate of change = 0) and cause more overshoot. The overshoot with no constraints is up to 1.1 m. We want to test the impact of: ๐Ÿ‘‰ Position constraint: [-1.15, 1.15] m ๐Ÿ‘‰ Position constraint: [-1.05, 1.05] m ๐Ÿ‘‰ Position constraint: [-1.02, 1.02] m โœ… ๐—ฆ๐—ถ๐—บ๐˜‚๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฅ๐—ฒ๐˜€๐˜‚๐—น๐˜ The simulation is performed directly in MATLAB using the command ๐˜€๐—ถ๐—บ, for 6 seconds, on the nominal system, with the 3 different combinations of constraints listed above. We can observe how the MPC algorithm changes its control approach to prevent the controlled variable (the position) from going above the constraint. I find this feature of MPC fascinating. The next steps will be: ๐Ÿ‘‰ More constraints ๐Ÿ‘‰ 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 3 (Constraints on Controlled Variable) | NatokHD