Documentation

getNumOutputsImpl

Class: matlab.System
Package: matlab

Number of outputs from step method

Syntax

num = getNumOutputsImpl (obj)

Description

num = getNumOutputsImpl (obj) returns the number of outputs from the step method.

If your step method has a variable number of outputs (uses varargout), implement the getNumOutputsImpl method in your class definition file to determine the number of outputs. Use nargout in the stepImpl method to assign the expected number of outputs.

If the number of outputs expected by the step method is fixed (does not use varargout), the object determines the required number of outputs from the step method. In this case, you do not need to implement the getNumOutputsImpl method.

getNumOutputsImpl is called by the getNumOutputs method, if the number of outputs has not been determined already.

    Note:   You must set Access = protected for 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 the Nontunable attribute.

Input Arguments

obj

System object™

Output Arguments

num

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

Examples

collapse all

Set Number of Outputs

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

methods (Access = protected)
   function num = getNumOutputsImpl(~)
      num = 2;
   end
end

Set Number of Outputs to Zero

Specify that the step method does not return any outputs.

methods (Access = protected)
   function num = getNumOutputsImpl(~)
      num = 0;
   end
end

Use nargout for Variable Number of Outputs

Use nargout in the stepImpl method when you have a variable number of outputs and will generate code.

methods (Access = protected)
   function varargout = stepImpl(~,varargin)
      for i = 1:nargout
         varargout{i} = varargin{i}+1;
      end
   end
end
Was this topic helpful?