Convert a string of numbers to a number.

1 view (last 30 days)
Convert a string of numbers to a number without using str2num.

Accepted Answer

Abhishek Jain
Abhishek Jain on 5 Oct 2016
You can use the following code.
a=[1 2 3];
It converts an array containing digits to a number.
Hope that helps.

More Answers (1)

Jos (10584)
Jos (10584) on 5 Oct 2016
Look mammy, no hands!
S = '6387'
N1 = sscanf(S,'%d')
N2 = (S - '0') * (10.^(numel(S)-1:-1:0)).'
% N3 = ...


Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by