How to define dependent dimensions in argument validation block
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Error Detection and Correction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!