File Exchange

image thumbnail

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

version 1.1 (3.48 KB) by

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

2 Downloads

Updated

View License

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')

Comments and Ratings (2)

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.

Richard Crozier

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

Updates

1.1

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

MATLAB Release
MATLAB 7.12 (R2011a)
Tags Add Tags

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

» Watch video