Main Content

matlab.lang.correction.AppendArgumentsCorrection Class

Namespace: matlab.lang.correction

Correct error by appending missing input arguments

Description

Use AppendArgumentsCorrection objects in functions that throw an MException object. MException uses AppendArgumentsCorrection instances to display suggestions for missing input arguments.

Creation

Description

aac = matlab.lang.correction.AppendArgumentsCorrection(arguments) creates a correction that suggests appending input arguments to the function call that threw the MException object.

Note

If arguments includes name-value arguments, use name=value syntax to avoid syntax errors. For more information, see Name=Value in Function Calls

example

Input Arguments

expand all

Suggested arguments, specified as a string or character vector, or a cell array of character vectors.

Examples

collapse all

The function hello requires one input argument. Add a suggested input argument "world" to the error message.

function hello(audience)
if nargin < 1
    aac = matlab.lang.correction.AppendArgumentsCorrection('"world"');
    error(aac, 'MATLAB:notEnoughInputs', 'Not enough input arguments.')   
end
fprintf("Hello, %s!\n", audience)
end

Call the function without an argument.

hello
Error using hello (line 4)
Not enough input arguments.

Did you mean:
>> hello("world")

Version History

Introduced in R2019a

See Also

Functions

Properties