필터 지우기
필터 지우기

check String for letters ?

조회 수: 2 (최근 30일)
Max Müller
Max Müller 2014년 9월 27일
편집: per isakson 2014년 9월 27일
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
  댓글 수: 1
Max Müller
Max Müller 2014년 9월 27일
see ya tomorrow

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

채택된 답변

per isakson
per isakson 2014년 9월 27일
편집: per isakson 2014년 9월 27일
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개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by