str2num
Convert character array or string to numeric array
Description
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(txt
)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.
Note
Security Considerations:
str2num
is implemented using eval which might lead to
undesired side effects. When calling str2num
with
untrusted user input, use Evaluation='restricted'
or
str2double
to avoid
unexpected code execution.