Your problem is not with str2num (although using str2num is not recommended, but that's another topic).
Your problem is more fundamental is that the only thing that
does is display the output(s) of the function to the command line and then immediately discards the output(s) since it's not stored in anything.
somevariable = somefunc(whateverinput);
on the other hand does store that output in somevariable.
In effect, your call to erase does nothing since you never store ther result of erasing 'x' and your call to str2num does nothing since you never store its output either. Therefore you're summing the character of your numbers variable which still contains your original input '1x1x1'.