0

I am trying to load a very large set of data in Matlab. I was previously using the command 'importdata()', which makes a matrix out of the content of your .txt or your .dat, for instance. The problem I have now encountered is that I am using very large datasets, which are actually bigger than the memory in my computer. How can I import only a certain part of that file to Matlab at a time (i.e., so that I do not have the problem of running out of memory because I load the entire file at once)?

Thank you!

Edit: I am using MATLAB R2018a

  • Only 2 options: (1) Read the doc for [`memmapfile`](https://mathworks.com/help/matlab/ref/memmapfile.html) and see it this can be useful to you (if you have data well structured in your file it might be ok), or (2) fallback method is to use the low level file reading functions (`textscan/fscanf/fread/...`) and read your file one chunk at a time. If you go that way, here's a bit of inspiration (the question is not exactly yours but some of the answers could still apply) : https://stackoverflow.com/q/9440592/3460361 – Hoki Jun 25 '20 at 15:08
  • You can do it manually using low-level read functions such as `fread` in a loop, or automatically using [`datastore`](https://www.mathworks.com/help/matlab/datastore.html) – Luis Mendo Jun 25 '20 at 15:32

0 Answers0