主要内容

matlab.metadata.Argument Class

Namespace: matlab.metadata

Describe argument of function or method

Since R2026a

Description

The matlab.metadata.Argument class provides information about a specific input or output argument of a function or method.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate a matlab.metadata.Argument object directly. The Inputs and Outputs properties of matlab.metadata.CallSignature are of type Argument.

Properties

expand all

Argument name and group name, specified as a matlab.metadata.ArgumentIdentifier instance. The instance specifies the argument name in its Name property. For a name-value argument, the GroupName property specifies the group name of the argument.

For functions that are part of the MATLAB® executable, the Name property value is varargin for input arguments and varargout for output arguments.

Attributes:

GetAccess
public
SetAccess
private

This property is currently not used.

Attributes:

GetAccess
public
SetAccess
private

This property is currently not used.

Attributes:

GetAccess
public
SetAccess
private

Indicates if the argument is required, specified as a logical 0 or 1. If the value is 1, the argument is required.

Attributes:

GetAccess
public
SetAccess
private

Indicates if the argument is repeating, specified as a logical 0 or 1. If the value is 1, the argument is repeating.

Attributes:

GetAccess
public
SetAccess
private

Indicates if the argument is a name-value argument, specified as a logical 0 or 1. If the value is 1, the argument is a name-value argument.

Attributes:

GetAccess
public
SetAccess
private

Describes the validation the argument uses, if any, specified as a matlab.metadata.ArgumentValidation instance. The instance describes any size, class or validation functions used in the argument definition. If the argument does not use validation, the property value is an empty array.

Attributes:

GetAccess
public
SetAccess
private

Describes the default value of the argument, if any, specified as a matlab.metadata.DefaultArgumentValue instance. The instance describes the value itself and whether the value depends on any other arguments. If the argument is required, this property value is an empty array.

Attributes:

GetAccess
public
SetAccess
private

The class that defines options for a name-value argument, specified as a matlab.metadata.Class instance. When a name-value argument is defined using the ?ClassName syntax, this property identifies ClassName. If the name-value argument is not defined using this syntax, the property is an empty array. See Name-Value Arguments from Class Properties for more information.

Attributes:

GetAccess
public
SetAccess
private

Examples

collapse all

Save the function plotEllipse on your path.

function plotEllipse(a,b,center,lineOpts)
% plotEllipse  Plot an ellipse
% Plots an ellipse using the inputs a and b as the semi-major
% and semi-minor axes. center is an optional input that specifies
% the coordinates of the center of the ellipse. Specify Color and 
% LineStyle as optional name-value arguments. 

    arguments
        a {mustBeNumeric,mustBePositive}
        b {mustBeNumeric,mustBePositive}
        center (1,2) {mustBeNumeric} = [0 0]
        lineOpts.Color {mustBeTextScalar} = "black"
        lineOpts.LineStyle {mustBeTextScalar} = "-"
    end
    
    angle = linspace(0,2*pi);
    xval = a*cos(angle) + center(1);
    yval = b*sin(angle) + center(2);

    plot(xval,yval,Color=lineOpts.Color,LineStyle=lineOpts.LineStyle)
    axis equal
end

To get information about the function using introspection, call metafunction to create a matlab.metadata.Function instance. Access the Signature property. The property shows that the function has five input arguments and uses an input arguments block.

mf = metafunction("plotEllipse");
ms = mf.Signature
ms = 

  CallSignature with properties:

                 Inputs: [1×5 matlab.metadata.Argument]
                Outputs: [1×0 matlab.metadata.Argument]
     HasInputValidation: 1
    HasOutputValidation: 0

Access the matlab.metadata.Argument instance that describes the first input . The metadata shows that the identifier is a, and it is a required argument. The function also uses argument validation for a, which is described by the matlab.metadata.ArgumentValidation instance stored in the Validation property of Argument.

ms.Inputs(1)
ans = 

  Argument with properties:

             Identifier: a
            Description: ''
    DetailedDescription: ''
               Required: 1
              Repeating: 0
              NameValue: 0
             Validation: [1×1 matlab.metadata.ArgumentValidation]
           DefaultValue: [0×0 matlab.metadata.DefaultArgumentValue]
            SourceClass: [0×0 matlab.metadata.Class]

Access the fourth input argument. The metadata shows that the identifier is lineOpts.Color, and it is a name-value argument that does not have a source class.

ms.Inputs(4)
ans = 

  Argument with properties:

             Identifier: lineOpts.Color
            Description: ''
    DetailedDescription: ''
               Required: 0
              Repeating: 0
              NameValue: 1
             Validation: [1×1 matlab.metadata.ArgumentValidation]
           DefaultValue: [1×1 matlab.metadata.DefaultArgumentValue]
            SourceClass: [0×0 matlab.metadata.Class]

Version History

Introduced in R2026a