The str2double function is taking too long?
이전 댓글 표시
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
KSSV
2021년 6월 10일
Why and how you have an array of number of dimension 46259*503 into a string?
Joel Lynch
2021년 6월 10일
편집: Joel Lynch
2021년 6월 10일
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
2021년 6월 10일
편집: xingxingcui
2021년 6월 10일
Walter Roberson
2021년 6월 10일
T3 = readmatrix('_040825_1735_IS.log', 'delimiter',' ');
That gives 46264 rows, 502 variables, everything already numeric.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!