string that may or may not need to be converted to num...
Show older comments
I am bringing a string into a function. I need to convert it to num ONLY if it's intended as a number like 2, 40, 100... but when the user enters it as something else, leave it as a string. Can that be done?
Thanks!
Accepted Answer
More Answers (1)
Walter Roberson
on 24 Sep 2018
1 vote
str2double() and test for nan, keep the original if you got nan.
Categories
Find more on Data Type Conversion 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!