I have a script in which a string of number is entered
string='123'
or
string='9823'
I am trying to convert this to an array of the form [a, b, c, d] for example, from the string '123' to a number array [1,2,3]
Any tips on how to do this?
str = '123'; num = str - '0'; % num = [1 2 3];
use str2num() function
str2num()
str = '123'; str = str2num(str);
Note. To make sure I'm right, type "whos str" in the command window and check the class. A string has a class, char, and numeric values have a class, double
You can use cellstr:
cellstr('123') ans = { [1,1] = 123 }