Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

nargin (MathScript Function) (Windows, Not in Base Package)

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Member of the support class.

Syntax

c = nargin

Description

Returns the number of input arguments you supply to the function that calls nargin. You can use nargin 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. If you attempt to call nargin outside of a user-defined function, MathScript always returns 0.

Examples

Outputs

Name Description
c Returns the number of input arguments you supply to the function that calls nargin. c is an integer.

Examples

Save the following script as integerdivision.m in the LabVIEW Data directory. The script uses nargin 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 nargin and nargout.
if nargin<2
divisor = 1;
end
quotient = floor(dividend / divisor);
if nargout>1
remainder = rem(dividend, divisor);
end

After you save integerdivision.m, call the following commands in the LabVIEW MathScript Window or the MathScript Node.

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

Related Topics

nargout


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit