str2double

Returns a scalar, complex number or matrix, R, after converting the input s.

Syntax

R = str2double(s)

Inputs

s
Type: string | cell

Outputs

R
If a conversion fails, Nan is returned. If s is a cell array of size greater than 1, R will be a matrix of the same dimensions as s.
Type: scalar | complex number | matrix

Examples

String to scalar:
R = str2double('2.345e+5')
R = 234500
String to complex:
R = str2double('24 + 7i')
R = 24 + 7i
Matrix of strings to matrix of numbers:
R = str2double(['65', '66'; '88', '92'])
R = [Matrix] 2 x 1
6566
8892
Cell array to matrix:
R = str2double({'45', '4', 5; 'pi' 99, '134 + 45i'})
R = [Matrix] 2 x 3
45 + 0i    4 + 0i  NaN +  0i
NaN + 0i  NaN + 0i  134 + 45i