MATLAB: Convert String to Numerical Matrix

matrix

Hi there,
Just wondering how to convert some matrix string (such as A = '[1,2,3,4,5]') into a numerical matrix (like [1,2,3,4,5]) so that it displays when entered into matlab like,
ans =
1 2 3 4 5
instead of
Columns 1 through 5
1.0000 2.0000 3.0000 4.0000 5.0000
Cheers,
Samuel

Best Answer

Normally str2num() is not suggested:
Wanted = sscanf(A(2:end-1), '%d').' % edited after sir Walter’s comment to exclude []