I'm trying to write a function to change arrays to hash values, I've done it so that I can change a numerical array into their hash values but I can't seem to figure out how to change string arrays into their hash values.
I'm having trouble doing it with string arrays. for example if array= [aced]
this is my code so far.
function [h]=Hash31(array1)
n=length(array1);
i=1;
h=0;
if array1
for i=1:1:n
h=array1(i)+31*h;
end
end
and it turns a numerical array into their hash value. I was wondering if I had to do some kind of conversion or logical to make it work and if I did to that how would I fit it into the existing function. would it have to be a logical, because I've tried using an if function but I don't know how to write in code 'if the array is string, then...' in a way that Matlab understands.