2

I used profile to check my code for speeding up 90% of my code is going on for

open('filename.mat')

I am looking for ways to speed it up all the files are .mat with around 40K lines on 13 columns I was wondering if you know a way to speed it up, maybe changing it to

load('filename.mat')

Is there a speed difference between them?

JohnnyF
  • 1,053
  • 4
  • 16
  • 31
  • Check [this](https://www.mathworks.com/matlabcentral/answers/40111-reading-and-writing-faster-a-mat-file) out. First hit on Google. In short, using the option `'-v6'` when saving mat-files increases the speed of reading them – buzjwa Apr 30 '15 at 08:05
  • 1
    You might also want to check what's going on in your `%TEMP%` folder, see [this answer](http://stackoverflow.com/a/16413252/1714410) that might be related. – Shai Apr 30 '15 at 08:20
  • are you using linux or windows machine? – Shai Apr 30 '15 at 10:48
  • running on both, the profiler was done for windows – JohnnyF Apr 30 '15 at 10:51
  • Is it possible that the files are not stored locally, but in a network drive? if you need to go through net to get to files it can take very long. – Shai Apr 30 '15 at 12:29
  • one more thing, try and give absolute paths to filenames so Matlab will not need to resolve paths. – Shai Apr 30 '15 at 12:29

1 Answers1

2

open has to determine the file type - if it determines it to be a .mat file it will call load.

I wouldn't have expected it to take very long to do that though...

Are you loading files over a network?

Are you running out of RAM?

To answer your question I would expect changing to load to speed things up but not by a lot... Try it and see! :)

matlabgui
  • 5,642
  • 1
  • 12
  • 15