필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how can i convert a string to a number (without using the str2num function) so if the string represents a number the value is 1? (otherwise the value is 0)...

조회 수: 1 (최근 30일)
for example:
st = '23487';
r = 1;
(also '00023487' is acceptable or any number of leading zeros).
but
st = '-4e';
r = 0;
  댓글 수: 1
Daniel Shub
Daniel Shub 2012년 11월 23일
I am closing this question. Please edit it to include what you have tried so far.

답변 (2개)

Arthur
Arthur 2012년 11월 23일
r = ~isnan(str2double(st));

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 23일
a='1.3125';
r=numel(regexp(a,'[0-9.]'))==numel(a)

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by