Programming > Functions

62 functions in MATLAB › Programming > Functions.

Argument Definitions

addOptionalAdds an optional positional argument to an inputParser.
addParameterAdds a name-value argument to an inputParser.
addParamValueOlder name of addParameter for adding a name-value argument.
addRequiredAdds a required positional argument to an inputParser.
inputnameReturns the name of the variable passed as a given argument of the current function.
inputParserParses and validates the arguments of a function.
mfilenameReturns the name of the file that is running.
mustBeAChecks that a value belongs to one of the given classes.
mustBeFileChecks that text names existing files.
mustBeFiniteChecks that no element is Inf, -Inf or NaN.
mustBeFloatChecks that a value is of class double or single.
mustBeFolderChecks that text names existing folders.
mustBeGreaterThanChecks that every element is strictly greater than a bound.
mustBeGreaterThanOrEqualChecks that every element is greater than or equal to a bound.
mustBeInRangeChecks that every element lies between two bounds.
mustBeIntegerChecks that every element is a whole number.
mustBeLessThanChecks that every element is strictly less than a bound.
mustBeLessThanOrEqualChecks that every element is less than or equal to a bound.
mustBeMemberChecks that a value is one of the elements of a set.
mustBeNegativeChecks that every element is less than zero.
mustBeNonemptyChecks that an array has at least one element.
mustBeNonmissingChecks that the input has no missing values.
mustBeNonNanChecks that no element is NaN.
mustBeNonnegativeChecks that every element is zero or greater.
mustBeNonpositiveChecks that every element is zero or less.
mustBeNonsparseChecks that an array is stored in full, not sparse, form.
mustBeNonzeroChecks that no element is zero.
mustBeNonzeroLengthTextChecks that text is non-empty.
mustBeNumericChecks that a value is a numeric array.
mustBeNumericOrLogicalChecks that a value is numeric or logical.
mustBePositiveChecks that every element is greater than zero.
mustBeRealChecks that a value has no imaginary part.
mustBeScalarOrEmptyChecks that a value is a single element or has none.
mustBeSparseChecks that an array is sparse.
mustBeTextChecks that a value is text: characters, a string array or a cell array of character vectors.
mustBeTextScalarChecks that a value is a single piece of text.
mustBeUnderlyingTypeChecks that an array has the given underlying class.
mustBeValidVariableNameChecks that text is a valid MATLAB variable name.
mustBeVectorChecks that a value is a vector.
namedargs2cellConverts a scalar structure into a cell array of name-value pairs.
nargchkOld-style check of the number of input arguments; superseded by narginchk.
narginchkChecks that a function was called with an acceptable number of input arguments.
nargoutchkChecks that a function was called with an acceptable number of output arguments.
parseMethod of inputParser that matches a call's arguments against the declared parameters.
validatecolorValidates a color specification and returns it as an RGB triplet.
validatestringMatches text against a list of valid strings, allowing abbreviations.

Error Handling

assertRaises an error if a condition is false.
errorThrows an error, stopping the running code unless it is caught.
lasterrReturns the message of the most recent error.
lasterrorReturns a struct describing the most recent error (obsolete).
lastwarnReturns or sets the most recent warning message.
onCleanupCreates an object that runs a function when it is cleared or goes out of scope.
warningDisplays a warning message and records it, without stopping the program.

Scope Variables and Generate Names

assigninAssigns a value to a variable in the base or caller workspace.
genvarnameBuilds valid, unique variable names from text (superseded by matlab.lang.makeValidName).
isvarnameTests whether text is a valid variable name.
matlab.lang.makeUniqueStringsMakes strings unique by appending numbers to the ones that collide.
matlab.lang.makeValidNameConverts text into valid variable or field names.
mislockedTests whether a function file is locked in memory.
mlockLocks the running function in memory so that clear does not reset it.
munlockAllows a locked function or script file to be cleared from memory again.
namelengthmaxMaximum length of a variable, function or field name.