Skip to content

Instantly share code, notes, and snippets.

@kyamagu
Created October 29, 2013 02:57
Show Gist options
  • Save kyamagu/7208518 to your computer and use it in GitHub Desktop.
Save kyamagu/7208518 to your computer and use it in GitHub Desktop.
Calculate a hash value for a string or a numeric/logical array.
function number = hash(value)
%HASH Calculate a hash for a string or a numeric/logical array.
if ~ischar(value)
value = num2str(value);
end
number = typecast(int32(java.lang.String(value).hashCode()), 'uint32');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment