How to check the type of input

How would I be able to check for the correct input value for a function, say I'm expecting a number but instead they put in a character?

 Respuesta aceptada

Mischa Kim
Mischa Kim el 1 de Mzo. de 2014
Editada: Mischa Kim el 1 de Mzo. de 2014

0 votos

Sarah, use the isnumeric command (see example here). Or use validateattributes as a more advanced concept.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Mzo. de 2014
Editada: Azzi Abdelmalek el 1 de Mzo. de 2014
Use class function
s='err'
class(s)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Mzo. de 2014

Editada:

el 1 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by