Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

str2double - Convert string to double-precision value

Syntax

X = str2double('str')
X = str2double(C)

Description

X = str2double('str') converts the string str, which should be an ASCII character representation of a real or complex scalar value, to the MATLAB double-precision representation. The string can contain digits, a comma (thousands separator), a decimal point, a leading + or - sign, an e preceding a power of 10 scale factor, and an i for a complex unit.

If str does not represent a valid scalar value, str2double returns NaN.

X = str2double(C) converts the strings in the cell array of strings C to double precision. The matrix X returned will be the same size as C.

Examples

Here are some valid str2double conversions.

str2double('123.45e7')
str2double('123 + 45i')
str2double('3.14159')
str2double('2.7i - 3.14')
str2double({'2.71' '3.1415'})
str2double('1,200.34')

See Also

char, hex2num, num2str, str2num

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS