Main Content

get

Get property values from MPC object

Description

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.

example

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

example

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.

example

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

Examples

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

mpcobj=mpc(plant,1);

Get values of some properties

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

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

% display all properties
get(mpcobj)
                          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
WholeMPCStruct=get(mpcobj);

% display History field
WholeMPCStruct.History
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.

Tips

An alternative to the syntax

Value = get(MPCobj,'PropertyName')

is the structure-like referencing

Value = MPCobj.PropertyName

For example,

MPCobj.Ts
MPCobj.p

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

See Also

| |

Introduced before R2006a