How to Create a Random UUID in Matlab

Generating a universally unique identifier (UUID) can be very useful for a variety of tasks where you need a unique way to identify something. While a UUID is not technically guaranteed to be unique, the identifier space is so large (128-bit) that it can be treated as unique for most purposes.

It is simple to generate a UUID string in MATLAB by using its built in Java Virtual Machine:

uuid = char(java.util.UUID.randomUUID);

The function java.util.UUID.randomUUID() will return an object of type java.util.UUID, but this can be typecasted into a MATLAB string through the char() function. Simple!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">