Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert string to number array in matlab

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?

like image 772
user1612925 Avatar asked Aug 20 '12 23:08

user1612925


1 Answers

str = '123';
num = str - '0';
% num = [1 2 3];
like image 162
Eastsun Avatar answered Oct 15 '22 11:10

Eastsun