This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

nargin

Number of input arguments for System object

Syntax

numInputs = nargin(obj)
nargin

Description

example

numInputs = nargin(obj) returns the number of input arguments that are required by the obj algorithm definition. This function is a System object™ extension of the general nargin function.

If your System object uses the matlab.system.mixin.Nondirect class, nargin returns the number of input arguments for the updateImpl and outputImpl methods.

nargin returns the number of input arguments specified in the call to the currently executing System object. Use this syntax in the body of a System object only.

Examples

collapse all

This example shows the output from nargin when used on a System object AddUp with variable-sized input.

A marker System object is defined as follows:

classdef AddUp < matlab.System
   methods(Access = protected)
        function y = stepImpl(obj,u,varargin)
            % Implement algorithm.
            y = u + sum([varargin{:}]);
        end     
    end
end

Create the object and call nargin.

total = AddUp();
nargin(total)
ans = 
    -2

Input Arguments

collapse all

System object to query.

Output Arguments

collapse all

This argument represents the number of inputs needed to call the System object.

If the output is nonnegative, the number of inputs cannot change while the object is in use.

If the output is negative, the number of inputs can change from call to call. This situation occurs when the System object does not override getNumInputsImpl and the stepImpl signature contains varargin.

Introduced in R2018a