isint.m 371 B

12345678910111213141516
  1. function f = isint(m)
  2. % function f = isint(m)
  3. %
  4. % <m> is a matrix
  5. %
  6. % return a logical matrix the same size as <m>.
  7. % an element is 1 iff it is a float and finite and exactly equal to an integer.
  8. % specifically:
  9. % f = isfloat(m) & isfinite(m) & m==round(m);
  10. %
  11. % example:
  12. % isequal(isint([1 1.5 NaN Inf]),[1 0 0 0])
  13. % do it
  14. f = isfloat(m) & isfinite(m) & m==round(m);