How to check the type of input

19 views (last 30 days)
Sarah
Sarah on 1 Mar 2014
Edited: Azzi Abdelmalek on 1 Mar 2014
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?

Accepted Answer

Mischa Kim
Mischa Kim on 1 Mar 2014
Edited: Mischa Kim on 1 Mar 2014
Sarah, use the isnumeric command (see example here). Or use validateattributes as a more advanced concept.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 1 Mar 2014
Edited: Azzi Abdelmalek on 1 Mar 2014
Use class function
s='err'
class(s)

Community Treasure Hunt

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

Start Hunting!