Convert a matrix of strings to a matrix of doubles.
r = csv_stringtodouble(strs) r = csv_stringtodouble(strs,convertStrToNan)
a m-by-n matrix of strings.
a 1-by-1 matrix of booleans (default convertStrToNan=%t). If %t it converts no valid string to Nan. If %f a no valid string returns a error.
a m-by-n matrix of doubles.
Convert a matrix of strings to a matrix of double.
This function is faster than evstr to convert a matrix convert a matrix of strings to a matrix of double.
The csv_stringtodouble
converts any complex number as a whole into a
complex numeric field, converting the real and imaginary parts to the
specified numeric type.
Valid forms for a complex number are :
Form | Example |
±<real>±<imag>i|j | 5.7-3.1i |
±<imag>i|%i|j | -7j |
csv_stringtodouble("123.45e7") csv_stringtodouble("123 + 45i") csv_stringtodouble("123 + 45%i") csv_stringtodouble("123 + 45*%i") csv_stringtodouble("3.14159") csv_stringtodouble(["2.71" "3.1415"]) mA = string(1:100); r = csv_stringtodouble(mA) r = csv_stringtodouble("2.6 + 3j") r = csv_stringtodouble("2.6 + 3*%i") r = csv_stringtodouble("2.6 + 3%i") csv_stringtodouble("not a number") csv_stringtodouble("not a number", %t) csv_stringtodouble("not a number", %f) | ![]() | ![]() |
In the following script, we compare the performances of the evstr
and csv_stringtodouble
functions.
Typical values of t1/t2
are between 3 and 10.
For large values of n
, the previous script can fail because
of a lack of memory, while csv_stringtodouble
may succeed.
Copyright (C) 2010-2011 - DIGITEO - Allan CORNET
Copyright (C) 2011 - DIGITEO - Michael Baudin