Initialize System object
setupImpl( implements one-time tasks.
setupImpl is called via the
setup method. Users never call the
setup method directly. But,
setup is called the first time a System object is run and after a System object has been released. For details, see Detailed Call Sequence
Method Authoring Tips
If your System object does not require any setup tasks, you can omit this method from your class definition file.
setupImplto set private properties so they do not need to be calculated each time
stepImplmethod is called.
To acquire resources for a System object, you must use
setupImplinstead of a constructor.
You must set
Access = protectedfor this method.
Do not use
setupImplto initialize or reset states. For states, use the
If the System object will be used in the Simulink® MATLAB System (Simulink) block, you cannot modify any tunable properties in the
Do not use the
setupImplmethod to set up input values.
obj — System object
System object handle used to access properties, states, and methods specific to the object. If
setupImpl method does not use the object, you can replace this
input1,input2,... — Inputs to the
inputs to the System object
List the inputs to the System object. The order of inputs must match the order of inputs defined in the
stepImpl passes the inputs
setupImpl to use the specifications, such as size and data
types in the one-time calculations.
Setup a File for Writing
This example shows how to open a file for writing using the
setupImpl method in your class definition file.
methods (Access = protected) function setupImpl(obj) obj.pFileID = fopen(obj.Filename,'wb'); if obj.pFileID < 0 error('Opening the file failed'); end end end
Initialize Properties Based on Object Inputs
This example shows how to use
setupImpl to specify that
running the object initializes the properties of an input. In this case, calls to run the object, which includes
u, initialize the object states in a matrix of size u.
methods (Access = protected) function setupImpl(obj, u) obj.State = zeros(size(u),'like', u); end end
Introduced in R2011b