MATLAB Answers

0

How to convert string to number?

Asked by akshatha nayak on 6 May 2019
Latest activity Edited by Stephen Cobeldick on 6 May 2019
we have extracted a value from GUI using
id1=get(handles.id1,'String');
Now i want to check if the value is a number. How do i do this?
If the value is a number that is converted to a string using the above line, how do I convert it back to a number?

  1 Comment

KSSV
on 6 May 2019
Read about ischar, str2num, num2str,

Sign in to comment.

1 Answer

Answer by Stephen Cobeldick on 6 May 2019
Edited by Stephen Cobeldick on 6 May 2019

"...how do I convert it back to a number?"
Convert to numeric:
num = str2double(id1)
"Now i want to check if the value is a number"
isn = ~isnan(num)

  0 Comments

Sign in to comment.