x = str2num(s)
[x, ok] = str2num(s)
| Parameter | Description |
|---|---|
| s | a character vector or string scalar holding a numeric expression. |
| Parameter | Description |
|---|---|
| x | the numeric result, or [] when the text cannot be evaluated to a number. |
| ok | a logical: true when the conversion succeeded. |
x = str2num(s) converts the character array s to a numeric array by evaluating it.
Because str2num evaluates its input, prefer str2double for simple scalar conversions.
x = str2num('[1 2 3]')
[y, ok] = str2num('4 5; 6 7')
| Version | Description |
|---|---|
| 2.0.0 | initial version |