Main Content

setname

Set I/O signal names in MPC plant model

Description

example

setname(MPCobj,'input',i,name)changes the name of theith input signal inMPCobjtoname. This is equivalent toMPCobj。Model.Plant.InputName{i}=name, and both commands and also update the read-onlyNamefield of the corresponding structure inMPCobj。ManipulatedVariables(if the input is a manipulate variable), orMPCobj。DisturbanceVariables(if the input is a disturbance variable).

setname(MPCobj,'output',i,name)changes the name of theith output signal inMPCobjtoname. This is equivalent toMPCobj。Model.Plant.OutputName{i} =name, and both commands and also update the read-onlyNamefield of the corresponding structure inMPCobj。OutputVariables.

Examples

collapse all

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

mpcverbosityoff;% turn off mpc messages% create plant modelplant = rss(4,4,4);% random state spaceplant.D = 0;% set D matrix to zero% set signals type in plant modelplant = setmpcsignals(plant,'MV',1,'MD',3,'UD',4,'MO',1,'UO',[3 4]);% create MPC objectmpcobj = mpc(工厂,1);% sampling time = 1 second

Set names of input signals

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

Check names of input signals

% get input signal namesgetname(mpcobj,'input',2)% get name of second input signalans ='Joe'% alternativelympcobj.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 cellarray{'Jim'} {'Joe'} {'Jeff'} {'UD1'}

Set and check names of output signals

% set output signal namessetname(mpcobj,'output',1,'Laura')% set name of first output signalsetname(mpcobj,'output',2,'Diana')% set name of second output signalsetname(mpcobj,'output',3,'Emily')% set name of third output signal% get output signal namesgetname(mpcobj,'output',2)% get name of second input signalans ='Diana'% alternativelympcobj.OutputVariables(2).Name ans ='Diana'mpcobj.Model.Plant.OutputName{2} ans ='Diana'mpcobj.Model.Plant.OutputName ans = 4×1 cellarray{'Laura'} {'Diana'} {'Emily'} {'UO2'}

Note that signals not specified withsetmpcsignalsare 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, usempc.

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

Signal number to be set.

Example:2

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

For input signalsnamereplaces the content ofMPCobj。Model.Plant.InputName{i}, as well as the read-onlyNamefield of the corresponding structure inMPCobj。ManipulatedVariables(if the input is a manipulate variable), orMPCobj。DisturbanceVariables(if the input is a disturbance variable).

For output signalsnamereplaces the content ofMPCobj。Model.Plant.OutputName{i}, as well as the read-onlyNamefield of the corresponding structure inMPCobj。OutputVariables.

Tips

Note

TheNamefields of the variable-related structures inManipulatedVariables,OutputVariables, andDisturbanceVariablesinMPCobjare read-only. You must usesetnameto assign signal names, or equivalently modify theModel.Plant.InputNameandModel.Plant.OutputNameproperties of the MPC object.

Note

Neither of theNameproperties for the signals inMPCobjaffects 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 usingsetmpcsignalon the plant object, and recreate the MPC object for that plant, or you need to recreate all the affected controller signal structures and usesetto assign them to the MPC object (not recommended).

Version History

之前介绍过的R2006a