mustBeFolder
Checks that text names existing folders.
Category: Programming > Functions
Syntax
mustBeFolder(A)
Checks that every path in A refers to an existing folder. Returns nothing if the check passes and throws an error if not.
Description
mustBeFolder is a validator: it inspects its input and either returns silently or raises an error with the identifier MATLAB:validators:mustBeFolder. The error message states the requirement that was violated, so the caller sees what was expected rather than a generic failure.
A can be a character vector, a string array or a cell array of character vectors. The error message lists the folders that were not found.
Input arguments
A- The value to check. Any array of the class the validator accepts.
Example
Passing and failing input
mustBeFolder(pwd);
disp('passed')
try
mustBeFolder('nofolder')
catch err
disp(err.message)
end
Output
passed
The following folders do not exist: 'nofolder'.