Change sampling time of an MPC controller
Use the Model Predictive Control Toolbox™
d2d function to change the sampling time of an MPC controller (see
mpc for background).
To resample a generic discrete-time LTI dynamical system instead, see
returns the controller
newmpc = d2d(
newmpc, which is identical to
MPCobj except for the new sample time
This is equivalent to coying
MPCobj in a new object
newmpc and assigning a new sample using either
newmpc are sampled or resampled when the QP matrices must be
computed, for example when
mpcmove are called.
Create a plant, a corresponding MPC object, and create a new controller with a different sampling time.
mpcverbosity off; % turn off mpc messaging plant=tf(1,[1 1]); % create plant (note the steady state gain) mpcobj=mpc(plant,1); % create mpc object (1 second sampling time) newmpc=d2d(mpcobj,0.2); % change sampling time to 0.2 seconds newmpc.Ts ans = 0.2000 newmpc.Ts=1; % change sampling time back to 1 second compare(newmpc,mpcobj) % compare the two controllers ans = logical 1
newTs— Sampling Time
This is the new sampling time for the returned, resampled, MPC controller
newmpc— MPC controller with the new sampling time
This is the returned MPC controller, which is identical to
MPCobj except for the fact that its sampling time is now
newTs. The internal models of
sampled or resampled when the QP matrices must be computed for the MPC optimization
problem to be solved.(for example when
mpcmove are called).