The STR2DOUBLE function eliminates all commas from the input string before attempting to determine its numeric value. The STR2DOUBLE function does not have the ability to recognize misplaced commas or commas that are used as decimal separators.
To work around this issue, you must create your own MATLAB function that converts a string to a numeric value. The code in str2double.m can be used as a starting point. (Be sure you do not modify or overwrite the original version of str2double.m).
For example, if you would like to treat the comma as a decimal point and periods as the thousands separator, you can copy the code from str2double.m, rename the function, and change line 37 from:
to the following:
periods = (s == '.');
commas = (s == ',');
s(commas) = '.';
s(periods) = [];
Change the function calls in line 201 and 210 from:
to the following:
x(k) = newfunctionname(s{k});
Best Answer