Main Content

# tf

Convert unconstrained MPC controller to linear transfer function form

## Syntax

``ktf = tf(MPCobj)``

## Description

Use the Model Predictive Control Toolbox™ `tf` function to convert an unconstrained MPC controller to transfer function form (see `mpc` for background). The returned controller is equivalent to the original MPC controller `MPCobj` when no constraints are active. You can then use Control System Toolbox™ software for sensitivity analysis and other diagnostic calculations.

To create or convert a generic LTI dynamical system to zero/pole/gain form instead, see `tf` and Dynamic System Models.

example

````ktf = tf(MPCobj)` returns the linear discrete-time dynamic controller `ktf`, in transfer function form. `ktf` is equivalent to the MPC controller `MPCobj` when no constraint is active.```

## Examples

collapse all

Create a plant, a corresponding MPC object, and convert it to transfer function form.

```mpcverbosity off; % turn off mpc messaging plant=tf(1,[1 1],0.2); % create plant (0.2 seconds sampling time) mpcobj=mpc(plant,0.2); % create mpc object (0.2 second sampling time) ktf=tf(mpcobj) % convert mpc to transfer function ktf = From input "MO1" to output "MV1": 0.452 z^3 - 0.6781 z^2 - 1.506e-16 z ----------------------------------------- z^3 - 1.001 z^2 + 0.0002642 z + 0.0006399 Sample time: 0.2 seconds Discrete-time transfer function. ```

Plot the response to a step in the unmeasured disturbance input using both the `sim` command and the controller transfer function form.

```% create a plant and the corresponding mpc object mpcverbosity off; % turn off mpc messaging plant=tf({1,1},{[1 1],[1 1]},0.2); % create plant (0.2 seconds sampling time) plant=setmpcsignals(plant,'UD',2); % second input is a disturbance entering at mv mpcobj=mpc(plant,0.2); % create mpc object (0.2 second sampling time) % set input and output disturbance models (remove integrators) setindist(mpcobj,'model',tf(1)) % set input disturbance model to 1 setoutdist(mpcobj,'model',tf(1)) % set output disturbance model to 1 % closed loop output sensitivity cloffset(mpcobj) ans = 1.4472 % convert the controller and calculate closed loop transfer function ktf=tf(mpcobj); % convert mpc to transfer function Muy=feedback(plant(:,1),ktf,1); % closed loop transfer function from mv to y % closed loop output sensitivity using transfer function 1+dcgain(Muy*ktf) ans = 1.4472 % plot closed loop response to a step on the measured input step(Muy,10); % simulate using step % create option object to inject disturbance in simulation SimOptions = mpcsimopt; % create object SimOptions.UnmeasuredDisturbance = ones(50,1); % specify unmeasured input disturbance % simulate closed loop for 50 steps with sim and step and plot the response [y,t,u,xp]=sim(mpcobj,50,0,[],SimOptions); % simulate using sim % overlap the sim results on the plot hold on stairs(t,y,'r') hold off ```

## Input Arguments

collapse all

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use `mpc`.

## Output Arguments

collapse all

Transfer function form of the MPC controller `MPCobj` when no constraint is active. This is also equivalent to `tf(ss(MPCobj))`

## See Also

Introduced before R2006a

## Support

#### Implementing an Adaptive Cruise Controller with Simulink

Download technical paper