FUNCTION REFERENCE

str2double

Convert text to a double.

Convert text to a double.

Syntax

X = str2double(str)

str is a character row or a cell array. Each text holding one real or

complex number, such as '3.14', '-2.5e3', '1,000', 'Inf' or '1+2i', converts

to that number; anything else gives NaN. A cell array gives an array of its

shape, with NaN for elements that are not text.

Example

str2double({'3.14', 'abc'})   % [3.14 NaN]

String inputs are supported with bounded two-dimensional storage.

Example

str2double(["1.5" "bad"])

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.