View License

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

» Watch video

Highlights from
Temporary change directory

Be the first to rate this file! 1 Download (last 30 days) File Size: 2.42 KB File ID: #40150 Version: 1.0

Temporary change directory



Change directory and return to original when calling function finishes or exits with an error.

| Watch this File

File Information

    change current directory to DIR, but automatically return to
    original directory when the calling function or subfunction
    finishes or gets an error.

    Basically this function is equivalent with adding next code to your
        old_dir = cd(DIR);
        C = onCleanup(@()cd(old_dir));

    When CDTEMP is used multiple times in the same function or
    subfunction, then on exit current directory will be set to the
    first orginal directory.

    The CLEAR command will also change current directory to the first
    original directory.

    Change to new directory and return when the function that uses this
    command finishes.

    Change to new directory, do your things and return to original
see als cd, onCleanup, clear

Required Products MATLAB
MATLAB release MATLAB 7.6 (R2008a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us