Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does find in MATLAB return indices as double values?

The find function in MATLAB returns indices where the given logical argument evaluates true.

Thus I'm wondering, why are the returned indices of type double and not uint32 or uint64 like the biggest index into a matrix could be?

Another strange thing which might be connected to that here is, that running

[~,max_num_of_elem] = computer

returns the maximal number of elements allowed for a matrix in the variable max_num_of_elem which is also of type double.

like image 358
Bastian Ebeling Avatar asked Jan 27 '26 23:01

Bastian Ebeling


1 Answers

I can only guess, but probably because a wide range of functions only support double. Run

setdiff(methods('double'), methods('uint32'))

to see what functions are defined for double and not for uint32 on your version of MATLAB.

Also there is the overflow issue with integer data types in MATLAB that can introduce some hard to detect bugs.

like image 191
Mohsen Nosratinia Avatar answered Jan 29 '26 13:01

Mohsen Nosratinia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!