Table Of Contents

arginnum

Version:
    Last Modified: March 15, 2017

    Returns the number of input arguments you supply to the function that calls arginnum.

    Syntax

    c = arginnum
    Legacy name: nargin

    Outputs

    c

    Number of input arguments you supply to the function that calls arginnum. c is an integer.

    Usage

    You can use arginnum to determine if the number of inputs you supply to a function is less than the maximum number of inputs for that function. You then can assign default values to define the optional inputs, or you can use the error function to return an appropriate error message. If you attempt to call arginnum outside of a user-defined function, MathScript always returns 0.

    Copy the following script into a new MathScript inside your project. The script uses arginnum to determine if the number of inputs you supply to integerdivision is less than 2. The script then assigns a default value of 1 to the divisor input.

    function [quotient, remainder] = integerdivision(dividend, divisor)
    %This is an example for using arginnum and argoutnum.
         if arginnum<2
              divisor = 1
         end
    quotient = floor(dividend / divisor)
         if argoutnum>1
              remainder = rem(dividend, divisor)
         end

    After you copy the script into your project, call the following commands in the MathScript node.

    [x, y] = integerdivision(14, 3)
    [x, y] = integerdivision(14)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics