str2double
Convert string to double precision value
Syntax
X = str2double(str)
Description
X = str2double(
converts the text instr
)str
to double precision values.str
contains text that represents real or complex numeric values.str
can be a character vector, a cell array of character vectors, or a string array. Ifstr
is a character vector or string scalar, thenX
is a numeric scalar. Ifstr
is a cell array of character vectors or a string array, thenX
is a numeric array that is the same size asstr
.
r的文本epresents a number can contain digits, a comma (thousands separator), a decimal point, a leading+
or-
sign, ane
preceding a power of 10 scale factor, and ani
or aj
for a complex unit. You cannot use a period as a thousands separator, or a comma as a decimal point.
Ifstr2double
cannot convert text to a number, then it returns aNaN
value.