MATLAB Community

MATLAB, community & more

Function Name Case Sensitivity in MATLAB R2011b

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.

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.