Release 13 Release Notes |
Maximum Name Length Changed for Variables, Functions, Files
Prior to this release, the length of MATLAB identifiers (variable names, function and subfunction names, structure field names, M-file names, MEX-file names, and MDL-file names) was restricted to 31 characters. Names using more than 31 characters were either truncated by MATLAB or caused a warning or error to be generated.
In MATLAB 6.5, any of these names can be up to 63 characters long.
A new function, namelengthmax
, returns the maximum length for MATLAB identifiers.
If you have MATLAB programs that hard-code the maximum identifier length as 31, you should replace these hard-coded limits with a call to namelengthmax
.
If you use identifiers that exceed 63 characters, MATLAB issues a warning and truncates any characters beyond the 63rd.
Characters Beyond 31 Are No Longer Ignored
In previous versions of MATLAB, if you had two or more long identifiers in which the first 31 characters were identical, MATLAB ignored any characters beyond the 31st and thus recognized only one of the identifiers. For example, given these two Stateflow filenames
both appeared to MATLAB 6.1 as shown below, and MATLAB recognized only one of the files.
In MATLAB 6.5, with the maximum MDL-file name length increased to 63, MATLAB recognizes both files. You should be aware of this change, as it could possibly lead to unexpected behavior.
Warning for Identifiers Longer Than 31
In MATLAB 6.5, if you use an identifier that exceeds the previous limit of 31 characters, MATLAB can optionally generate a warning of the form:
This warning is disabled by default. You can enable it by typing
Note
Unlike most MATLAB warnings, you cannot enable this warning with the commands, warning on or warning on all . You must use the command shown above.
|
Warning for Identifiers Longer Than namelengthmax
If you specify an identifier that exceeds the new character limit, MATLAB generates the following warning:
<identifier> exceeds MATLAB's maximum name length of <namelengthmax> characters and has been truncated to <truncated_identifier>
This warning is enabled by default. You can disable it by typing the following command. However, we strongly encourage you to leave it enabled:
MATLAB Toolbox Functions Updated
MATLAB toolbox functions, such as isvarname
, have been updated in MATLAB 6.5 to make use of the namelengthmax
function, and thus return the correct values.
Effect on P-Code and MEX-Files
You should recompile the following files:
mxMAXNAME
New Products | Platform Limitations |