Reputation: 51
I have a script in which a string of number is entered
string='123'
or
string='9823'
I am trying to convert this into an array of the form [a,b,c,d] e.g from a string of '123' to a numerical array [1,2,3]
Any tips on how to do this?
Upvotes: 5
Views: 11110
Reputation: 1
use the function str2num()
str = '123';
str = str2num(str);
Note: To verify that i'm correct, type in 'whos str' in the command window, and check the class. A string has a class, char, and numeric values have a class, double
Upvotes: 0