MATLAB functions str2double and strsplit taking long time
古いコメントを表示
I have a comma separated string file like this:
number1, number2, number3, number4
number5, number6, number7, number8
number9, number10, number11, number12
.....................................
_[all the numbers are double]_
I am reading it line by line.
Then splitting the line into parts (',' is the delimiter) and converting the parts into double numbers.
The code is given below:
str2double(strsplit(line,','));
The input file is very big. It has >100000 lines and each line has >200 parts or numbers.
The Profiler shows the above code is taking long time to execute.
How to replace the above code thus it takes very short time to execute?
I want to read the file line by line. Do not want to read the whole file into a single Matrix using csvread.
Thanks in advance.
2 件のコメント
Stephen23
2018 年 1 月 9 日
Why not just use csvread? If the file is comma separated and contains only numbers, then why waste time writing buggy code when csvread already exists?
Arup Ghosh
2018 年 1 月 9 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!