matlab.System.getNumOutputsImpl - Number of outputs from System object - MATLAB (original) (raw)
Main Content
Class: matlab.System
Number of outputs from System object
Syntax
num = getNumOutputsImpl(obj)
Description
[num](#bs4ooab-1-num) = getNumOutputsImpl([obj](#bs4ooab-1%5Fsep%5Fmw%5F353aa417-3412-46f8-81f1-586adf7da5a8))
returns the number of outputs expected from the System objectâ„¢.
If the signature of stepImpl
or outputImpl
does not include varargout
, the System object can determine the number of outputs from the method signature. In this case, you do not need to implement the getNumOutputsImpl
method.
If the signature of stepImpl
or outputImpl
does include varargout
, you can implement thegetNumOutputsImpl
method in your class definition file to determine the number of outputs. You can use nargout
in the stepImpl
method to get the number of outputs the object was called with.
Method Authoring Tips
- 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 theNontunable
attribute.
Input Arguments
System object handle used to access properties, states, and methods specific to the object. If your getNumOutputsImpl
method does not use the object, you can replace this input with ~
.
Output Arguments
Number of outputs from the specified object, returned as an integer.
Examples
Specify the number of outputs (2, in this case) returned from the object.
methods (Access = protected) function num = getNumOutputsImpl(~) num = 2; end end
Specify that the object does not return any outputs.
methods (Access = protected) function num = getNumOutputsImpl(~) num = 0; end end
Use nargout
in the stepImpl
method when you have a variable number of outputs and want to generate code.
methods (Access = protected) function varargout = stepImpl(~,varargin) for i = 1:nargout varargout{i} = varargin{i}+1; end end end
Version History
Introduced in R2011b