matlab.System.setupImpl - Initialize System object - MATLAB (original) (raw)

Class: matlab.System

Syntax

setupImpl(obj) setupImpl(obj,input1,input2,...)

Description

setupImpl([obj](#bs43txn%5Fsep%5Fmw%5F353aa417-3412-46f8-81f1-586adf7da5a8)) implements one-time tasks.

setupImpl([obj](#bs43txn%5Fsep%5Fmw%5F353aa417-3412-46f8-81f1-586adf7da5a8),[input1,input2,...](#bs43txn%5Fsep%5Fmw%5Fcee6147f-e421-40a4-b75e-2f2097ee5356)) sets up a System objectâ„¢ using one or more of the stepImpl input specifications.

Run-Time Details

setupImpl is called via the setup method. Users never call thesetup 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

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your setupImpl method does not use the object, you can replace this input with ~.

List the inputs to the System object. The order of inputs must match the order of inputs defined in thestepImpl method. stepImpl passes the inputs into setupImpl to use the specifications, such as size and data types in the one-time calculations.

Examples

expand all

This example shows how to open a file for writing using thesetupImpl 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

Filename should be defined as a nontunable property of the System object

properties (Nontunable) Filename = "default.bin" end

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 input 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

Version History

Introduced in R2011b