matlab unique identifier based on number

528 views Asked by At

I'm looking for a unique identifier based on a float number in matlab, so hash functions came to mind. Does Matlab (our its less documented Java part, or even (windows) system commands) offer any possibilities for any hash function, such as MD5?

uniquehash=hash(5);
uniquehash=hash('asdf');

related: datahash script
Unique Identifier from java that may be of use: char(java.util.UUID.randomUUID)

As far as I've seen, this is not a duplicate as I need a unique identifier based on a float number. however let me know if it is...

1

There are 1 answers

1
Stephen C On BEST ANSWER

I need a unique identifier based on a float number.

Assuming that you are talking about a 64-bit floating point number, that means there can only be 2^64 (max) possible unique identifiers. You may as well either use the number itself as the identifier.

Using a crypto hash like MD5, SHA1, SHA2 etc doesn't make the number any more unique. At the end of the day, the 2^64 possible floating point numbers map to 2^64 possible hashes. Most of the 2^128 (or whatever) theoretically possible hashes simply cannot be generated.

(If you are talking about 32 bit floats, substitute 2^32 for 2^64!)