Replacing non-integer values

13 Ansichten (letzte 30 Tage)
Muneer
Muneer am 6 Dez. 2013
Kommentiert: sixwwwwww am 6 Dez. 2013
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!

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 6 Dez. 2013
a(ceil(a)~=a)=0

sixwwwwww
sixwwwwww am 6 Dez. 2013
Bearbeitet: sixwwwwww am 6 Dez. 2013
If 'a' is your array then use the following:
a(arrayfun(@(x) ~isinteger(x), a)) = 0;
  8 Kommentare
Muneer
Muneer am 6 Dez. 2013
Thanks, it works great!
sixwwwwww
sixwwwwww am 6 Dez. 2013
you are welcome

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by