How to define dependent dimensions in argument validation block
Show older comments
I'm writing a function that processes a matrix to which I'd like the to add an option name-value arguments.
The size of the optional argument needs to be the width or length of the InputMatrix to avoid errors and I'd like to keep do as much input validation as possible inside the arguments block.
Example Code
function [out] = somefun(InputMatrix, options)
arguments
InputMatrix (:,:) % size NxN where N!=0
option.ColumnNames (1, width(InputMatrix)) {mustBeText} % <- width argument not supported here
end
out = []
end
In this example I'd like to add some columnnames to the vector, for example for plotting. This needs to be the same size as the matrix.
If possible I'd like to avoid validating the size inside the function because it's easier to maintain inside of the arguments block.
Does anyone know of a way to force "arguments " to accept a variable or an clean alternative.
Accepted Answer
More Answers (0)
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!