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.

Examples

expand all

Return a value of -12.345.

X = srt2double("-12.345");

Return a value of 123400.

X = srt2double("1.234e5");

Tips

  • Use in Stateflow® charts that use C as the action language.

  • Enclose literal strings with single or double quotes.

Introduced in R2018a