File Exchange

image thumbnail


version (3.77 KB) by Jan
Check uniqueness of function names

1 Download

Updated 10 Jun 2010

View License

UniqueFuncNames - Check uniqueness of function names

If you install a large 3rd party toolbox, the file names may interfere with other installed toolboxes. This simple funtion compares the names of all M-, P- and Mex-files found in the Matlab path and displays non-unique names.

P- and Mex-files with the same name as a corresponding M-file are accepted, if they are found in the same folder.
Local subfunctions inside the M- or P-file and nested functions are not taken into account, because it is assumed, that a potential shadowing is wanted.
Class paths as "\@cell" and package paths as "\+mypackage" are not considered in this version.

INPUT: None.
OUTPUT: Logical flag, TRUE if the names are unique considering some
1. Files which are intentionally not unique:
"Contents.m" exists in each folder.
"prefspanel.m" exists in some folder to register control panels.
"messageProductNameKey" returns the product key for toolboxes.
2. Some user defined folders might contain functions, which are wanted to
shadow function of Matlab's or user define toolbox functions, e.g. to
improve them. Such folders must be inserted in a leading position in the
Matlab path. A further example is a folder, which contains Mex functions,
which are compiled for a specific Matlab version, e.g. if you run Matlab
6.5 (DLL) and 7 (MEXW32) simulataneously.
3. Further exceptions occur e.g. in Matlab 2009a:
Exclude one of them using the full file name including the path.
The exceptions depend on your installed toolboxes and have to be adjusted to
your machine. The corresponding lines are marked by '###' in the source.

I'd appreciate all comments and ideas for improvements and additions.

For further debugging see also:
FDEP (Us):

Cite As

Jan (2021). UniqueFuncNames (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)


@Adam: This function does not open any files - it does not contain any |fopen| command. Therefore I assume, that UniqueFuncNames is not responsible for not closed files.


Is there a minor issue with file handles being locked after running this. I had problems with my revision control system trying to delete some of the duplicated files highlighted by this because of denied access, but when I called 'fclose all' in Matlab after running it I was able to manipulate the files without problems.

Works very well in general though.


Great work -

Bruno Luong

Not test myself, but it looks quite interesting and useful tool. MATLAB user development environment can get into nightmare if the developer does not make great care about how functions are named and where they are located. This tool can help to sort out that kind of issue, and I'm sure Jan, Matt Fig, Us contributions are high quality.

Randall Plate

I just had an issue where a basic Matlab function (fir1) was working without any error messages but not producing correct output. Took me a while to figure out it was because a subfunction it was calling was being overridden by another function my path. This tool is exactly what I was looking for to check for other instances where this might be happening and going undetected.


Suggestions for the handling of \+package paths would be very welcome. Thanks!

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!