Hey Guys, I have an Editbox and I want to start my program only if the Editbox Input are only numbers. Unfortunately, get(handle.editbox,'String') gives the Input back as String. So how can i check whether the user only entered numbers ?
isnumeric wont work i guess

 채택된 답변

per isakson
per isakson 2014년 9월 27일
편집: per isakson 2014년 9월 27일

0 개 추천

One way
is_num = not( isnan( str2double( str ) ) );
or
is_num = not( isnan( str2double( get(handle.editbox,'String') ) ) );
&nbsp
Won't work if user inputs "nan" :-(
>> isnumeric( nan )
ans =
1

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2014년 9월 27일

편집:

2014년 9월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by