MATLAB: How to convert ‘123’ to [1,2,3]

charsnumvector

How to convert '123' to [1,2,3]? Which is the shortest way?

Best Answer

For single digits like you have, subtract '0':
s = '123'
numbers = s - '0'