Large data file I/O
1 view (last 30 days)
Show older comments
I am trying to speed up a bottle neck in our code. Currently, the output of one of our FORTRAN modules writes the data to a text file. The text file is saved as .m file. The m files is then loaded into MATLAB. An example would be
function x = my_data(x)
x.time = [LARGE AMOUNT OF DATA]
Now this read operation seems to cause MATLAB to run out of memory. The MATLAB help file suggests storing large amounts of data in MAT files because they are optimized for read/write operations and compress data as well. They say this is better than using low-level file I/O such as fopen. But since our data is being read as an “.m” is it still using such file I/O. My question is should we take the time to try to write that data from FORTRAN as a mat file instead of a “.m”.
0 Comments
Accepted Answer
Walter Roberson
on 17 Jan 2012
It appears to me that you would be better off writing a binary file. The speed might not be as good as a .mat file (because of no compression), but Fortran should have no problem writing a binary file whereas bringing in the .mat format can be a nuisance.
I would also suggest that it would be faster if you used
x.time = my_data(); %no argument
and
function times = my_data
times = fread(...);
end
This would avoid having to make a copy of x.
More Answers (0)
See Also
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!