필터 지우기
필터 지우기

How to detect any unsupported character other than number

조회 수: 3 (최근 30일)
Aditya
Aditya 2012년 1월 31일
편집: Matt J 2013년 10월 1일
I have series of data in my excel file. But there are some unsupported characters present in the file like 1 0, 0h0,0.>68,1L1 etc. I want to detect all of these using regular expression or any method and replace it by zero. My main moto is detect anything which is not a number and replace it by zero.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 31일
L(L < '0' | L > '9') = '0';
  댓글 수: 2
Aditya
Aditya 2012년 2월 6일
Can you please clarify your answer
Walter Roberson
Walter Roberson 2012년 2월 6일
L is the character string.
The code detects anything that is not a number and replaces it with 0.
The digits are all together as characters, in the order '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' . So anything less than '0' is not a digit and anything greater than '9' is not a digit.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by