inputParser does not throw error

2 visualizaciones (últimos 30 días)
Grzegorz Lippe
Grzegorz Lippe el 17 de Mzo. de 2022
Respondida: Matt J el 17 de Mzo. de 2022
I want to check, whether an input is a string. Why does it not work?
p = inputParser() ;
isString = @(x) (isvector(x) | isempty(x)) & ischar(x) ;
addParameter(p, 'property_name', isString) ;
isString(13) % yields False
parse(p, 'property_name', 13) % Throws no error

Respuesta aceptada

Matt J
Matt J el 17 de Mzo. de 2022
The validation function should be the 4th argument,
addParameter(p, 'property_name','', isString) ;

Más respuestas (0)

Categorías

Más información sobre Argument Definitions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by