主要内容

matlab.metadata.CallSignature Class

Namespace: matlab.metadata

Describe inputs and outputs of function or method

Since R2026a

Description

The matlab.metadata.CallSignature class provides information about the input and output arguments of a function or method.

Class Attributes

Sealed
true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate matlab.metadata.CallSignature directly. When you create a matlab.metadata.Function or matlab.metadata.Method instance, the Signature property of that instance is of type CallSignature.

Properties

expand all

Inputs to the function or method, specified as a matlab.metadata.Argument array. The order of the elements in the array matches the order of the input arguments in the signature.

Attributes:

GetAccess
public
SetAccess
private

Outputs from the function or method, specified as a matlab.metadata.Argument array. The order of the elements in the array matches the order of the output arguments in the signature.

Attributes:

GetAccess
public
SetAccess
private

Indicates if the function or method defines an input arguments block, specified as a logical 0 or 1. If the value is 1, the function or method defines an input arguments block. The value of this property does not depend on whether any of the arguments are defined with specific validators, like size, class, or validation functions. The presence or absence of the input arguments block is the only criteria.

Attributes:

GetAccess
public
SetAccess
private

Indicates if the function or method defines an output arguments block, specified as a logical 0 or 1. If the value is 1, the function or method defines an output arguments block. The value of this property does not depend on whether any of the arguments are defined using specific validators, like size, class, or validation functions. The presence or absence of the output arguments block is the only criteria.

Attributes:

GetAccess
public
SetAccess
private

Examples

collapse all

Save the function pythagoreanTriple on your path.

function side3 = pythagoreanTriple(side1,side2)
% pythagoreanTriple  Check if two side lengths can form a Pythagorean triple
% If the two inputs can from a Pythagorean triple, the function returns the 
% third length. If no triple can be formed, the function returns -1.

    arguments (Input)
        side1 {mustBeInteger,mustBePositive}
        side2 {mustBeInteger,mustBePositive}
    end

    arguments (Output)
        side3 {mustBeInteger}
    end

    legleg = sqrt(side1^2 + side2^2);
    hypleg = sqrt(side1^2 - side2^2);
    leghyp = sqrt(side2^2 - side1^2);

    if (legleg == round(legleg)) && (legleg > 0)
        side3 = legleg;
    elseif (hypleg == round(hypleg)) && (hypleg > 0)
        side3 = hypleg;
    elseif (leghyp == round(leghyp)) && (leghyp > 0)
        side3 = leghyp;
    else 
        side3 = -1;
    end
end

To get information about the function using introspection, call metafunction to create a matlab.metadata.Function instance. Access the Signature property of the result. The Signature property shows that there are two input arguments and one output argument (described by instances of matlab.metadata.Argument) and that the function includes both input and output arguments blocks.

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

  CallSignature with properties:

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

Access the first element of the Inputs array for information about the first input argument.

ms.Inputs(1)
ans = 

  Argument with properties:

             Identifier: side1
            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]

Version History

Introduced in R2026a