필터 지우기
필터 지우기

Replacing non-integer values

조회 수: 5 (최근 30일)
Muneer
Muneer 2013년 12월 6일
댓글: sixwwwwww 2013년 12월 6일
I have an array of all numeric values but it is a mix of integers and non-integers. How could I replace an non-integer with 0, for example? Also, the array is fairly large (about 130k rows).
Thanks in advance!

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 6일
a(ceil(a)~=a)=0

sixwwwwww
sixwwwwww 2013년 12월 6일
편집: sixwwwwww 2013년 12월 6일
If 'a' is your array then use the following:
a(arrayfun(@(x) ~isinteger(x), a)) = 0;
  댓글 수: 8
Muneer
Muneer 2013년 12월 6일
Thanks, it works great!
sixwwwwww
sixwwwwww 2013년 12월 6일
you are welcome

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by