Main Content

getNumOutputsImpl

Class:matlab.System

Number of outputs fromSystem object

Syntax

num = getNumOutputsImpl(obj)

Description

num= getNumOutputsImpl(obj)returns the number of outputs expected from the System object™.

If the signature ofstepImploroutputImpldoes not includevarargout, the System objectcandetermine the number of outputs from the method signature. In this case, you do not need to implement thegetNumOutputsImplmethod.

If the signature ofstepImploroutputImpldoes includevarargout, you can implement thegetNumOutputsImplmethod in your class definition file to determine the number of outputs. You can usenargoutin thestepImplmethod to get the number of outputs the object was called with.

Method Authoring Tips

  • You must setAccess = protectedfor this method.

  • You cannot modify any properties in this method.

  • If you set the return argument,num, from an object property, that object property must have theNontunableattribute.

Input Arguments

expand all

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

Output Arguments

expand all

Number of outputs from the specified object, returned as an integer.

Examples

expand all

Specify the number of outputs (2, in this case) returned from the object.

methods (Access = protected)functionnum = getNumOutputsImpl(~) num = 2;endend

Specify that the object does not return any outputs.

methods (Access = protected)functionnum = getNumOutputsImpl(~) num = 0;endend

Usenargoutin thestepImplmethod when you have a variable number of outputs and want to generate code.

methods (Access = protected)functionvarargout = stepImpl(~,varargin)fori = 1:nargout varargout{i} = varargin{i}+1;endendend
Introduced in R2011b