主要内容

matlab.metadata.ArgumentIdentifier Class

Namespace: matlab.metadata

Name and group name of function argument

Since R2026a

Description

The matlab.metadata.ArgumentIdentifier class provides the name and group name of a function or method argument. For example, the group name of the LineStyle and LineWidth name-value arguments of plotRectangle is lineOptions.

function plotRectangle(width,height,lineOptions)
    arguments
        width double
        height double
        lineOptions.LineStyle (1,1) string = "-"
        lineOptions.LineWidth (1,1) {mustBeNumeric} = 1
    end
    ...
end

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate a matlab.metadata.ArgumentIdentifier object directly. The Identifier property of matlab.metadata.Argument is of type ArgumentIdentifier.

Properties

expand all

Name of the function argument, specified as a character vector.

Attributes:

GetAccess
public
SetAccess
private

Group name of the argument if it is a name-value argument, specified as a character vector. For positional arguments, the property value is an empty character vector.

Attributes:

GetAccess
public
SetAccess
private

Examples

collapse all

Save the function plotEllipse to 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 (Input)
        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 for the plotEllipse. 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 Identifier property of the Inputs property of the fourth input argument. The matlab.metadata.ArgumentIdentifier instance specifies the name and group name of the name-value argument.

ms.Inputs(4).Identifier
ans = 

  ArgumentIdentifier with properties:

         Name: 'Color'
    GroupName: 'lineOpts'

Version History

Introduced in R2026a