Main Content

str2double

Convert string to double precision value

Description

example

X = str2double(str) converts the text in string str to a double-precision value.

str contains text that represents a number. Text that represents a number can contain:

  • Digits

  • A decimal point

  • A leading + or - sign

  • An e preceding a power of 10 scale factor

If str2double cannot convert text to a number, then it returns a NaN value.

Note

The operator str2double is supported only in Stateflow® charts that use C as the action language.

Examples

expand all

Return a value of -12.345.

X = srt2double("-12.345");

Stateflow chart that uses the str2double operator in a state.

Return a value of 123400.

X = srt2double("1.234e5");

Stateflow chart that uses the str2double operator in a state.

Tips

Enclose literal strings with single or double quotes.

Introduced in R2018a