Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Slow loading of .mat files

Subject: Slow loading of .mat files

From: Mark Drakesmith

Date: 21 Jun, 2011 14:34:04

Message: 1 of 7


Hi.

I am experiencing a progressive slowing down of Matlab (r2010a on Windows 7 Pro x64) when loading variables form mat files.

I have a loop where I load a structure on each iteration. The variables are not too big (approx 2Mb). I find it gets slower loading the variables with each iteration, to the point where i have to terminate and restart the session.
I have used tic/toc to time how long it takes to load the files on each iterations. The time to load increases considerably:

Iteration Size (Mb) Time to load (s)
1 2.2201 6.7984
2 2.2541 9.5072
3 1.9966 12.5465
4 2.2100 11.5915
5 2.2003 18.5795
6 2.1955 15.7271
7 2.0191 14.071
8 2.1719 638.1973
9 2.0433 789.7458

I have loaded field iteratively (usually much larger ones than this) without experiencing this problem. I have restarted my computer a number of times (including a hard reset) and it has not helped. I am experiencing it on a number of scripts that load variables iteratively and it only started recently. I am at a loss as to how to fix this.

Any help you can offer would be appreciated.

Thanks

Mark

Subject: Slow loading of .mat files

From: Mark Drakesmith

Date: 23 Jun, 2011 09:45:05

Message: 2 of 7

Just to update on this. I have tried using profiler to find out what is happening during a load. The longest item on the summary was about 0.1s even though the load took over 5 minutes! I really don't know what is happening.

Any help that can be offered would be appreciated.

Many thanks

Mark

Subject: Slow loading of .mat files

From: Sadik

Date: 23 Jun, 2011 10:51:02

Message: 3 of 7

Hi Mark,

Can you post the part of your code that you are using to load the files?

Best.

Subject: Slow loading of .mat files

From: Mark Drakesmith

Date: 23 Jun, 2011 12:10:20

Message: 4 of 7

"Sadik " <sadik.hava@gmail.com> wrote in message <itv5qm$9ja$1@newscl01ah.mathworks.com>...
> Hi Mark,
>
> Can you post the part of your code that you are using to load the files?
>
> Best.

Here is a simplified version of the loop I have been running. All i am doing on this version is loading the variables and then clearing them. Even on this version I still suffer the same problem.

 Another thing I've noticed it only seems to effect structure variables. Double, single, etc.. variables seem to be OK.

Many thanks

Mark

------------------

load subj_params.mat subjcode eventcode

start_subj=[2:3 5:8 10:16];

selecttrials=[{1} {[2 3]} {[]} {[]} {5}];


for subj=start_subj;
    subj
    cd('..');
    cd(subjcode(subj,:));


    
    for event=[1 2 5]
        
         v_name=[subjcode(subj,:) eventcode(event,:)];

         load(['mne_pow_' v_name '.mat'],'source2'); % this is where the problem starts

         clear source2
        
    end
    
end

Subject: Slow loading of .mat files

From: Sadik

Date: 23 Jun, 2011 23:35:23

Message: 5 of 7

Sorry, no suggestions coming to my mind.

Subject: Slow loading of .mat files

From: Kirill

Date: 25 Jun, 2011 16:24:58

Message: 6 of 7

If MAT files are saved in Version 7.3, -v7, they are compressed by
default and it takes a lot of time to uncompress them on loading.

Try –v6 format if it is faster.

Kirill

Subject: Slow loading of .mat files

From: Mark Drakesmith

Date: 28 Jun, 2011 16:01:04

Message: 7 of 7

Kirill <kirillandreev@gmail.com> wrote in message <ea54e64b-7ae8-49eb-8851-dbc81847f359@d22g2000yqn.googlegroups.com>...
> If MAT files are saved in Version 7.3, -v7, they are compressed by
> default and it takes a lot of time to uncompress them on loading.
>
> Try –v6 format if it is faster.
>
> Kirill

Thanks for the advice, Kirill. Just re-saved my .mat files as v6 and it have improved the performance of my scripts substantially with no inexplicable slowing down.

Thanks very much!

Mark

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us