String to Double Conversion in MATLAB
Advertisement
This page provides MATLAB source code for converting a string to a double number, similar to the str2double
function. The str2double
MATLAB function converts a string input to a double-precision output value.
output = str2double(str1)
If str1
does not contain a valid scalar value, the function returns NaN
(Not a Number).
str1
can be a single element or an array.
Example:
str2double({'2.50' '4.222'})
Another Example:
str1 = '1.25 + 50i'
output = str2double(str1)
This would produce the following output:
output =
1.2500 +50.0000i