How to check the type of input
19 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
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.
0 Comments
More Answers (1)
Azzi Abdelmalek
on 1 Mar 2014
Edited: Azzi Abdelmalek
on 1 Mar 2014
Use class function
s='err'
class(s)
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!