"Benedikt F" <email@example.com> wrote in message news:firstname.lastname@example.org... > I want to count the occurrences of a number in a vector, for which I found > 'tabulate'. > This vector is of data type 'double' and contains random IDs, that is, 1e5 > distinct integers between 1 and 1e9. Using 'tabulate' will now give me a > vector with 1e9 rows, the most of which contain zeros (in second and third > column), which I don't want. > Clearly, I can rather easily get rid of them (like result = > result(logical(result(:,2)), :) ); I could also just add 0.1 to the whole > thing before tabulating and round the first row afterwards. Still, both > seems like rather much useless calculation; is there a more elegant > solution? > > Code example: > A = [1 2 1 1 4]; > isinteger(A) % 0, so why does tabulate treat it as integer?!
ISINTEGER checks the _type_ of the input, not the _value_ of the input. A is an array of type double, not an array of one of the eight integer types (int8, int16, int32, int64, uint8, uint16, uint32, or uint64) or a subclass of one of those eight types. Because of this ISINTEGER correctly returns false.