The str2double function is taking too long?
Ältere Kommentare anzeigen
The built-in function "str2double" is very time consuming when I want to convert an array of string type to an array of numertic type, especially when I have an array of string type with many elements(46259*503 size). Is there any way to improve the performance?
my os: win10
matlab 2021a
当我准备把一个string类型的数组(46259*503 大小)转换为numertic类型数组时候,此内置函数“str2double”非常耗时,特别是我的string类型数组较多元素的时候。请问有什么办法可以提高性能?
4 Kommentare
KSSV
am 10 Jun. 2021
Why and how you have an array of number of dimension 46259*503 into a string?
Joel Lynch
am 10 Jun. 2021
Bearbeitet: Joel Lynch
am 10 Jun. 2021
If you are actually extracting that much data, then if it is formatted in a regular pattern, you should be able to speed up reading the data using sscanf(), which works because time is not spent interpreting the strings
xingxingcui
am 10 Jun. 2021
Bearbeitet: xingxingcui
am 10 Jun. 2021
Walter Roberson
am 10 Jun. 2021
T3 = readmatrix('_040825_1735_IS.log', 'delimiter',' ');
That gives 46264 rows, 502 variables, everything already numeric.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!