I'm currently using textread to load a text file for later display in an edit field on my GUI. However, I'm in Linux, and discovered memory isn't freed up - so, my program got really slow, and I had to close MATLAB because I keep loading more and more text files. Is there a way to display my text file without loading the whole thing into memory?
Asked
Active
Viewed 127 times
1
-
3Matlab documentation recommends the use of `textscan`, not `textread`. However, this won't solve your problem. The problem is not so much the function, but the output. `textread`/`textscan` use cell arrays, which are a real memory hog. The most common solution to the problem is to import your file in chunks, and convert it to a less memory intensive format on-the-go. See [textscan-in-matlab-uses-excessive-ram-compared-to-similar-method-in-r](http://stackoverflow.com/questions/12475226/textscan-in-matlab-uses-excessive-ram-compared-to-similar-method-in-r) for more detail. – Colin T Bowers Dec 03 '12 at 02:46
1 Answers
0
Do it old-school, the UNIX-like way ... fopen, fread, fclose.
A = fread(fid, count, precision, skip, machineformat)
"count" gives you a length of data to read, "precision" is "uchar", "skip" is where to start reading. A is your char-array / string.

s-m-e
- 3,433
- 2
- 34
- 71