How to convert string to number?

조회 수: 7 (최근 30일)
akshatha nayak
akshatha nayak 2019년 5월 6일
편집: Stephen23 2019년 5월 6일
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
KSSV
KSSV 2019년 5월 6일
Read about ischar, str2num, num2str,

댓글을 달려면 로그인하십시오.

답변 (1개)

Stephen23
Stephen23 2019년 5월 6일
편집: Stephen23 2019년 5월 6일
"...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)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by