I can barely remember a MATLAB version that did not produce an inexact case match warning if you used the wrong capitalization of a function name. Now, the days of willy-nilly capitalization in MATLAB are over. Starting in R2011b, that long-time warning is now an error.
Here is the warning message in R2010a by calling “foo.m” with the command “Foo“:
Warning: Could not find an exact (case-sensitive) match for 'Foo'. ../foo.m is a case-insensitive match and will be used instead. You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly. Alternatively, you can disable this warning using warning('off','MATLAB:dispatcher:InexactCaseMatch'). This warning will become an error in future releases.
As promised, R2011b is the future release where this is now an error:
Cannot find an exact (case-sensitive) match for 'Foo'. Do you want: foo (in ../foo.m)?
This error identifier for this message is the same as the old warning: 'MATLAB:dispatcher:InexactCaseMatch'. If you still have any misspelled functions in your code, they should be spot by running the code and looking for these errors. Before launching your main script, run the command:
dbstop if error MATLAB:dispatcher:InexactCaseMatch
and your program will pause whenever this error occurs.
Comments are closed.
18 CommentsOldest to Newest
The first time I have seen this error message , it made me laugh. MATLAB throwns an error message but is able to detect which filename you have mispelled. So MATLAB would be able to run it but he doesn’t want anymore! lazy MATLAB ;)
But what if you didn’t want MATLAB to run foo.m when you typed Foo.m? What if you wanted MATLAB to run Foot.m but you forgot to type the last t?
That warning (now error) is the alert MATLAB gives you that there’s a potential problem. MATLAB not only tells you there’s a potential problem, it tells you what it plans to do about it. That way if MATLAB gets it wrong, you have enough information to know that MATLAB has the wrong idea and you can correct it.
MATLAB will also throw an error if the extension does not match exactly. This causes particular problems for .m files that have been renamed .M in R2011B (or maybe were always named .M). Changing foo.M to foo.m fixes the problem.
This has been spotted and reported elsewhere, but since this is the first hit I get searching for the error, I will leave this here (for when I forget the answer and need to look for it in the future ;-)
I would add that the change from .M to .m needs to be done outside of MATLAB (on Win XP, R2011B).
This change prompts me to suggest an improvement I have long since thought about regarding
If you have a function starting ‘DELME’, for example, and no other functions whose name starts
with this sequence of 5 letters (regardless of case), and you type ‘delm’, the tab select will
match to DELME* but it will preserve the case of the letters that you already typed, i.e. delm,
when you select the match offered, so you get delmE on completion even though there is no such
Alternatively if you have two functions which do start out matching, e.g. delme and DELME, and you
type in upper case DELM you will be offered the completion delme (which you cannot take because
you will get DELMe which does not exist as remarked above), even though the better match DELME
What users want is case insensitive matching to help you find the function you are after that when
chosen has the correct case. Although case insensitivity is desirable for tab-completion if you go
to the trouble of using upper-case and there is a closer case sensitive match to what you typed
this should be chosen by default in the tab-completion list.
And while on this topic I would finally add a small request, can the up and down arrows wrap
around, i.e. up from the first item in tab-completion selection box goes to the last item and
down-arrow from the last item takes you to the first.
What do other folk reckon?
Thanks for adding that bit about the file extension.
Those are great ideas. It’s been on our plan for a long time for tab completion to work in a manner similar to what you describe, but it’s not there yet.
Is there a script or a simple method to correct the letter case used for function calls in a set of m-files if a list of function names is provided, without manually going through each file?
No there’s not. Building such a tool is difficult for an interpreted language like MATLAB, as there is no good way of knowing if a symbol name is refers to a function or a variable, or if it were a function, if there will be a capital or lower-case named file on the path at the time is run.
This error is casuing me serious problems. Large libraries which were developed over years no no longer run. There are liliterally 100s of file to search through and correct.
Is there any possability to switch off this error as it was possible to switch off the warning?
Unfortunately there is not that I am aware of. We’ve had the warning on for years indicating that this was going to be an error, and this release was the one where we finally flipped it to error.
I don’t have a good solution for a large library. You can use a command like:
dbstop if error MATLAB:dispatcher:InexactCaseMatch
while will pause execution when the error is thrown, giving you a chance to fix the files one call at a time.
There might be a trick one can use with FIND and GREP to locate instances of mismatched case use in files and fix them, at least within a directory or two. I am not really an expert on putting those together, though.
I support Julian’s comment about tab completion.
Also, when I change folders using tab completion to find folder names folders the string returned from pwd and cd depends on what was input to tab-completion and cd, i.e., they don’t return the actual configuration of capital and non-capital letters in the folder name.
This causes problems when script files are named after folder name and executed from other scripts using
directory = deblank(regexp(pwd, ‘\’,’split’));
as the case sensitive eval does no longer evaluate the file if a wrong capitalization arises from the tab completion.
If anyone know a better way to implement the automatic naming and evaluation of files based on folder name, please let me know :)
Hi, I have two question. Firstly, in our group we share our MATLAB source code with SVN, unfortunately, it seems that’s not possible to commit changes that are only change capitalization under windows – hence this error is difficult for us to fix – one work around would be to change the function calls rather than the filenames but it’s not ideal…
Secondly, is there a way of locating all potential case mismatched in a large source code base, without have to run every code path…
That’s basically the two problem we face to upgrade MATLAB to the latest version. Any suggestion would be welcome.
@paradize , you may try fixcase :
MATLAB 4 on WINDOWS forced users to use lowecase names, while the OS, or more precisely FAT16, forced the filenames to be uppercase, including the filename extension. Users were forced to create inexact matches, because otherwise the code didn’t run.
I have still large libraries from this time. And now, TheMathWorks is telling me that they have changed their mind and now need a lowercase filename extension and matching filenames. According to Mathworks, I have to rewrite everything in order to be able to further use it. It is a complex and time consuming manual process, and it costs my company 100EUR per hour.
Why is TheMathWorks intentionally implementing such user-unfriendly not-backwards-compatible harassments in their code? Dont’t they think about their customers? Can’t you imagine that your users have better things to do than constantly updating their code basis to keep everything running? Why is it not possible at least to switch off this error, as it was the case with the warning?
The Warning Message was not telling me that this would be converted to an error. It only said that there could be performance impacts. Here is the warning from MATLAB 7.5.0:
Warning: Could not find an exact (case-sensitive) match for .
.m is a case-insensitive match and will be used instead.
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
Please provide a fix for this problem as quickly as possible!!!
I have the same problem as Mr Bernd Eppinger. I have literally over half a million files created over two decades of using MATLAB. This ad-hoc approach from what has become a standard engineering software is unacceptable. I am going to rethink if I should integrate MATLAB or not in my next edition of my text book (which currently endorses MATLAB). Backward compatibility is a must as anybody who has pursued research can testify.
Please fix this as soon as possible.
With much hope that reason will prevail to ensure longevity for MATLAB.
Moreover, on a Mac running OSx 5, the filename of the matlab file shows up in the current folder with capitalization, while the mac folder is lower case. This sets up two parallel directories and MATLAB thinks that there is a duplicate m file in the path.
If you have a fix for that without making all my filenames lower case, I would love to hear it.
Aurelien is right, the solution is here: http://www.mathworks.com/matlabcentral/fileexchange/36539&watching=36539#comments
also that error can appear if file name have extension “name.M”
changing to “name.m” helped to solve that problem