Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting char to integer at matlab [duplicate]

Possible Duplicate:
convert string to number array in matlab

I have a vector y including values '1' '2' '3' char values and I want to convert it to a corresponding integer vector. If I used str2num it gives 49 50 51 like numbers. How could I do it ?

like image 972
erogol Avatar asked Jan 03 '13 21:01

erogol


1 Answers

y - '0'

Subtracts the ASCII value for '0' from each vector element, taking advantage of the fact that the ASCII values for digits are contiguous.

like image 124
Oliver Charlesworth Avatar answered Sep 24 '22 04:09

Oliver Charlesworth