Specifications

4 Designing Controllers Using the Command Line
4-20
When the switch input is 1 the block automatically activates the first controller listed
(MPC1), which is appropriate when the masses are separated. When the switch input is
2 the block automatically enables the second controller (MPC2).
The following code simulates the controller performance
Tstop=100; % Simulation time
y1initial=0; % Initial M1 and M2 Positions
y2initial=10;
open('mpc_switching');
sim('mpc_switching',Tstop);
The figure below shows the signals scope output.