Demonstrates online MPC for LTI system
mpt_demo_lti2
A = [1 1; 0 1]; B = [1; 0.5];
lti = LTISystem('A', A, 'B', B);Alternativelly, we can import from state-space objects: s = ss(tf(1, [1 0 0])); d = c2d(s, 1); lti = LTISystem(d); Define the MPC controller
horizon = 5;
ctrl = MPCController(lti, horizon);Add state constraints
ctrl.model.x.min = [-5; -5];
ctrl.model.x.max = [5; 5];Add input constraints
ctrl.model.u.min = -1;
ctrl.model.u.max = 1;Set quadratic state penalty
ctrl.model.x.penalty = QuadFunction(eye(2));Set quadratic input penalty
ctrl.model.u.penalty = QuadFunction(1);Obtain the optimal control input for a given initial condition.
x0 = [-4; 0]; Uonl = ctrl.evaluate(x0)
Uonl = 1
◀ | mpt_demo_deployment_explicitmpctracking | mpt_demo_functions2 | ▶ |
© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk