Main Content

setname

Set I/O signal names in MPC plant model

Description

example

setname(MPCobj,'input',i,name) changes the name of the ith input signal in MPCobj to name. This is equivalent to MPCobj.Model.Plant.InputName{i}=name, and both commands and also update the read-only Name field of the corresponding structure in MPCobj.ManipulatedVariables (if the input is a manipulate variable), or MPCobj.DisturbanceVariables (if the input is a disturbance variable).

setname(MPCobj,'output',i,name) changes the name of the ith output signal in MPCobj to name. This is equivalent to MPCobj.Model.Plant.OutputName{i} =name, and both commands and also update the read-only Name field of the corresponding structure in MPCobj.OutputVariables.

Examples

collapse all

Create a plant and an MPC object, and then set the names of some input and output signals.

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

% set signals type in plant model
plant = setmpcsignals(plant,'MV',1,'MD',3,'UD',4,'MO',1,'UO',[3 4]);

% create MPC object
mpcobj=mpc(plant,1);                        % sampling time = 1 second

Set names of input signals

% set input signal names
setname(mpcobj,'input',1,'Jim')            % set name of first input signal
setname(mpcobj,'input',2,'Joe')            % set name of second input signal
setname(mpcobj,'input',3,'Jeff')           % set name of third input signal

Check names of input signals

% get input signal names
getname(mpcobj,'input',2)                   % get name of second input signal
ans =
    'Joe'

% alternatively
mpcobj.ManipulatedVariables(2).Name
ans =
    'Joe'

mpcobj.DisturbanceVariables(1).Name
ans =
    'Jeff'

mpcobj.Model.Plant.InputName{3}
ans =
    'Jeff'

mpcobj.Model.Plant.InputName
ans =
  4×1 cell array
    {'Jim' }
    {'Joe' }
    {'Jeff'}
    {'UD1' }

Set and check names of output signals

% set output signal names
setname(mpcobj,'output',1,'Laura')           % set name of first output signal
setname(mpcobj,'output',2,'Diana')           % set name of second output signal
setname(mpcobj,'output',3,'Emily')           % set name of third output signal

% get output signal names
getname(mpcobj,'output',2)                   % get name of second input signal
ans =
    'Diana'

% alternatively
mpcobj.OutputVariables(2).Name
ans =
    'Diana'

mpcobj.Model.Plant.OutputName{2}
ans =
    'Diana'

mpcobj.Model.Plant.OutputName
ans =
  4×1 cell array
    {'Laura'}
    {'Diana'}
    {'Emily'}
    {'UO2'  }

Note that signals not specified with setmpcsignals are assumed to be measured inputs (for non-specified inputs) or measured outputs (for non-specified outputs).

Input Arguments

collapse all

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

This integer specify that the name of the ith signal needs to be set.

Signal number to be set.

Example: 2

This is the name to be assigned to the ith input or output signal in MPCobj. This does not affect whether the signal is categorized as a manipulated variable, measured or unmeasured disturbance, measured or unmeasured output.

For input signals name replaces the content of MPCobj.Model.Plant.InputName{i}, as well as the read-only Name field of the corresponding structure in MPCobj.ManipulatedVariables (if the input is a manipulate variable), or MPCobj.DisturbanceVariables (if the input is a disturbance variable).

For output signals name replaces the content of MPCobj.Model.Plant.OutputName{i}, as well as the read-only Name field of the corresponding structure in MPCobj.OutputVariables.

Tips

Note

The Name fields of the variable-related structures in ManipulatedVariables, OutputVariables, and DisturbanceVariables in MPCobj are read-only. You must use setname to assign signal names, or equivalently modify the Model.Plant.InputName and Model.Plant.OutputName properties of the MPC object.

Note

Neither of the Name properties for the signals in MPCobj affects whether the signal is categorized as a manipulated variable, measured or unmeasured disturbance, measured or unmeasured output. To change the signal type you need to either reassign it using setmpcsignal on the plant object, and recreate the MPC object for that plant, or you need to recreate all the affected controller signal structures and use set to assign them to the MPC object (not recommended).

See Also

| |

Introduced before R2006a