Convert cell array of string number into numerical array

Post date: Nov 20, 2012 3:45:40 AM

This works for a cell array that contains only string of number, and not char. This can be useful when making a permutation vector from clustergram. Related post from StackOverflow.

>> mycell = {'5','-3','100','23','7'} mycell = '5' '-3' '100' '23' '7' >> mychar = char(mycell) mychar = 5 -3 100 23 7 >> numArray = str2num(mychar) numArray = 5 -3 100 23 7

So, in short, we just use

num2str(char(mycell))