%% Rebuild MPC MEX-Files for Custom QP Solver
%
% Create an MPC controller.

plant = rss(3,2,2);
plant.D = 0;
MPCobj = mpc(plant,0.1);

%
% Configure the controller to use a custom solver that supports code generation.

MPCobj.Optimizer.CustomSolverCodeGen = true;

%
% Copy a custom solver template file to the current working directory. To implement a custom solver, modify this template.

src = which('mpcCustomSolverCodeGen_TemplateEML.txt');
dest = fullfile(pwd,'mpcCustomSolverCodeGen.m');
copyfile(src,dest,'f');

%
% Rebuild the MPC MEX-files.

mpcBuildCustomSolver

% Copyright 2012 The MathWorks, Inc.