str2num

str2num(X, op) transforms matrix of strings X into a column vector of doubles. Set variable op to true (false by default), to handle non numeric strings, a non valid strings will be converted to NaN.

Examples

>> str2num('3.14')#

            3.14

>> class(ans)#

            double
>> str2num(['3' '1'; '5' '4'])#

            31
            54

>> class(ans)#

            double
>> t1 = table(['1';'2'],{'Marie'; 'John'},'Variablenames', {'ID','Name'})

>> str2num(t1.ID)#

            1
            2

>> class(ans)#

            double
>> str2num('str', true)#

 NaN

Resources

See also

class | strcat