View License

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

» Watch video

Highlights from
Generates free pathname for a file

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 2.05 KB File ID: #38442 Version: 1.1

Generates free pathname for a file



01 Oct 2012 (Updated )

Generates pathname to a non-existing file so you can save data without overwriting an existing file.

| Watch this File

File Information

Usage : filename = genfilename(fname)
This simple code will generate a 'free' pathname based on your suggestion (fname), to make sure you can save your data to a file without overwriting to an existing one.

Simple options allow you to use a certain number of digits or start numbering at a defined number.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
04 Oct 2012 Alexandre

(i did not know that function so thanks)
You are right, but one advantage of my script is that you still get control on the name of the file. It's basically for saving multiple versions of the same file, you will have a different number each time to avoid overwriting on the previous one.

Comment only
04 Oct 2012 Richard Crozier

You could just use the built-in tempname function

Comment only
05 Nov 2012 1.1

Faster for large number of existing files.

Contact us