Convert character array or string to numeric array
converts a character array or string scalar to a numeric matrix. The input can
include spaces, commas, and semicolons to indicate separate elements. If
X
= str2num(chr
)str2num
cannot parse the input as numeric values, then it
returns an empty matrix.
The str2num
function does not convert cell arrays or
nonscalar string arrays, and is sensitive to spacing around +
and
-
operators. In addition, str2num
uses
the eval
function, which can cause unintended side effects when
the input includes a function name. To avoid these issues, use str2double
.