Main Content


Get property values from MPC object


Use the Model Predictive Control Toolbox™ get function to read the property values of an MPC controller (see mpc for background).

To implement Get/Set interface of standard MATLAB object, see Implement Set/Get Interface for Properties.


PropertyValue = get(mpcobj,PropertyName) returns the current value of the property PropertyName of the MPC controller mpcobj.


Struct = get(mpcobj) converts the MPC controller mpcobj into a standard MATLAB® structure with the property names as field names and the property values as field values.


get(mpcobj) without a left-side argument displays all properties of mpcobj and their values.


collapse all

Create plant model and related MPC object

mpcverbosity off;                           % turn off mpc messages

% create plant model
plant = rss(4,4,4);                         % random state space
plant.D = 0;                                % set D matrix to zero


Get values of some properties

>> get(mpcobj,'Ts')
ans =
>> get(mpcobj,"Ts")
ans =
>> mpcobj.Ts
ans =
>> get(mpcobj,'ControlHorizon')
ans =
>> get(mpcobj,'Model')
ans = 
  struct with fields:

          Plant: [4×4 ss]
    Disturbance: []
          Noise: []
        Nominal: [1×1 struct]

% display all properties
                          Ts: 1                   
       PredictionHorizon (P): 10                  
          ControlHorizon (C): 2                   
                       Model: [1x1 struct]        
   ManipulatedVariables (MV): [1x4 struct]        
        OutputVariables (OV): [1x4 struct]        
   DisturbanceVariables (DV): []                  
                 Weights (W): [1x1 struct]        
                   Optimizer: [1x1 struct]        
                       Notes: {}                  
                    UserData: []                  
                     History: 11-Sep-2020 16:50:19

% get whole MPC structure

% display History field
ans =
   1.0e+03 *
    2.0200    0.0090    0.0110    0.0160    0.0500    0.0193

Input Arguments

collapse all

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

Specify PropertyName as a character array or string that contains the full property name (for example, 'UserData') or any unambiguous case-insensitive abbreviation (for example, 'user' instead of 'UserData'). You can specify any generic MPC property.

Example: 'Model'

Output Arguments

collapse all

The value returned in PropertyValue depends on the specific property of the MPC object. See mpcprops for more information on MPC object properties.

This is a standard MATLAB structure containing all the property names of the MPC object as field names and the property values as field values. See mpcprops for more information on MPC object properties.


An alternative to the syntax

Value = get(mpcobj,'PropertyName')

is the structure-like referencing

Value = mpcobj.PropertyName

For example,


return the values of the sampling time and prediction horizon of the MPC controller mpcobj.

Version History

Introduced before R2006a