View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

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

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

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


Vladimir (view profile)


14 May 2012 (Updated )

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

| Watch this File

File Information

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

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

Vladimir (view profile)

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.

Comment only
14 May 2012 Richard Crozier

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

Comment only
15 May 2012 1.1

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

Contact us