Code covered by the BSD License  

Highlights from

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




11 Sep 2013 (Updated )

Change the name of a function called in your m-files and optionally move it too.

| Watch this File

File Information

refactor the name of a function, changing all references to the function name in the path and moving the function file to the new named file


refactor_fcn_name(fcnname, newfcnname)
refactor_fcn_name(fcnname, newfcnname, topdir)
refactor_fcn_name(fcnname, newfcnname, topdir, domove)


refactor_fcn_name(fcnname, newfcnname) finds all uses of the function name in fcnname and replaces it with the string in newfcnname in the entire matlab path. The function must be function in an m-file on the Matlab path. By default the mfile containing the fuction is also then renamed to the new name.

refactor_fcn_name(fcnname, newfcnname, topdir) performs the same action but searching the folder provided in 'topdir' and all it's subdirectories rather than the entire Matlab path.

refactor_fcn_name(fcnname, newfcnname, topdir, domove) performs the same action but the 'domove' flag determines whether the function file is actually moved or not. If this evaluates to true the file is moved to the mfile with the new name, if false nothing is moved.

This function requires my other file exchange contributions 'regexprepfile' and 'samesize':


The refactoring is done by performing a regexprep in the files using the simple regex:



Samesize and Regexprepfile inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Other requirements This function requires my other file exchange contributions 'regexprepfile' and 'samesize':
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
12 Sep 2013 1.1

Added missing path2cell subfunction

Contact us