using attribute 'size' in validateattributes
Mostrar comentarios más antiguos
Hi,Any idea how I can pass size of a matrix to validateattributes? I need to check that size(A,2) < 2, where A is the input to my function.
Would be appreciated.
Respuesta aceptada
Más respuestas (1)
Daniel Lyddy
el 12 de Jun. de 2015
I think this might be what you want:
% set up validator
myValidMatrix = @(x) validateattributes(x, {'numeric'}, ...
{'real', '2d', 'size', [nan, 2]});
That nan in the 'size' vector is an "I don't care". If instead your array is 3D and you only care about the middle dimension, you would do:
myValidArray = @(x) validateattributes(x, {'numeric'}, ...
{'real', '3d', 'size', [nan, 2, nan]});
~Daniel
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!