num2str converts the integer number into a string representation of that number: 1234 becomes '1234', which is the same as ['1','2','3','4']. Now you've got one array entry per digit. Subtract '0' from there, then the char array will become a double array with value 0 where the char was '0', etc.