MATLAB: Convert cell array of strings to unicode quickly

doublestringsunicode2native

I have an array of approximately 10M strings, and I'm interested in converting each string to its unicode values. Is there a quick, one-line way to convert the whole string array into numeric values? Ideally, I'd love a solution like this:
numeric_matrix = double(string_array);
But of course double (and unicode2native) does not support cells. So my current solution is to loop through the string array:
for ii = 1:length(string_array)
numeric_matrix(ii,:) = double(string_array{ii});
end
Unfortunately this for-loop solution is very inefficient. It can take upwards of 10 minutes for very large numbers of strings. I tried googling this but didn't see anything better. Is there a simpler, faster way to do this, ideally in one line?

Best Answer

Try
numeric_array = cellfun(@uint16, stringarray);
Try it on a smaller subset first as I do not know how the timing would compare. It should have the advantage of not needing to change the internal representation.