Code covered by the BSD License  

Highlights from
Save and load data to a MAT-file in temporary directory

Be the first to rate this file! 12 Downloads (last 30 days) File Size: 3.48 KB File ID: #36671

Save and load data to a MAT-file in temporary directory

by

 

14 May 2012 (Updated )

Save and load temporary results to a MAT-file inside $TEMP$ directory

| Watch this File

File Information
Description

These save / load data to a MAT-file inside temporary directory. At most platforms temp directories are cleaned automatically at every boot, so these scripts are perfect for managing temporary results while keeping working directory clean (e.g. you don't need to care about erasing these *.mat files).

SAVETMP and LOADTMP are simply workaround of standard SAVE and LOAD functions and build in function TEMPDIR. E.g.
   savetmp file var1 var2
is identical to
   save(fullfile(tempdir,'file.mat'),'var1','var2')

MATLAB release MATLAB 7.12 (R2011a)
Other requirements Should work on all platforms
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
15 May 2012 Vladimir

Richard, thanks, I didn't know about it. I replaced "getmpdir" with standard "tempdir" in the updated version.

Basically, savetmp and loadtmp are just wrappers of save/load and tempdir functions, that allow to use command style, like:
savetmp mytemp a b c

It is a bit faster and more convenient than write
save([tempdir 'mytemp.mat'], 'a', 'b', 'c');

For instance, I use it a lot while debugging - I "savetmp" preliminary results that take long to calculate, then comment the section and "loadtmp" them.

14 May 2012 Richard Crozier

But what about the built in functions tempname and tempdir? How do these improve on them?

Updates
15 May 2012

"gettmpdir" was replaced by build in function "tempdir"

Contact us