MATLAB functions str2double and strsplit taking long time
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 9 Jan. 2018
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
am 9 Jan. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Large Files and Big Data 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!