Replacing non-integer values

6 次查看(过去 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!

请先登录,再进行评论。

类别

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