Built-in Function: str2double (s)
Convert a string to a real or complex number.
The string must be in one of the following formats where a and b are real numbers and the complex unit is 'i' or 'j':
- a + bi
- a + b*i
- a + i*b
- bi + a
- b*i + a
- i*b + a
If present, a and/or b are of the form [+-]d[,.]d[[eE][+-]d] where the brackets indicate optional arguments and 'd' indicates zero or more digits. The special input values
Inf,NaN, andNAare also accepted.s may also be a character matrix, in which case the conversion is repeated for each row. Or s may be a cell array of strings, in which case each element is converted and an array of the same dimensions is returned.
str2doublereturns NaN for elements of s which cannot be converted.
str2doublecan replacestr2num, and it avoids the security risk of usingevalon unknown data.See also: str2num