function f = isint(m) <m> is a matrix return a logical matrix the same size as <m>. an element is 1 iff it is a float and finite and exactly equal to an integer. specifically: f = isfloat(m) & isfinite(m) & m==round(m); example: isequal(isint([1 1.5 NaN Inf]),[1 0 0 0])
0001 function f = isint(m) 0002 0003 % function f = isint(m) 0004 % 0005 % <m> is a matrix 0006 % 0007 % return a logical matrix the same size as <m>. 0008 % an element is 1 iff it is a float and finite and exactly equal to an integer. 0009 % specifically: 0010 % f = isfloat(m) & isfinite(m) & m==round(m); 0011 % 0012 % example: 0013 % isequal(isint([1 1.5 NaN Inf]),[1 0 0 0]) 0014 0015 % do it 0016 f = isfloat(m) & isfinite(m) & m==round(m);