Hey, got installed the 2016b version on mac and it seems to not like programmes with long names: when i try to run this code directly step1_preproccessing_CL_TDT-170920-112847
gives me this error: Undefined function or variable 'step1_preproccessing_CL_TDT'.
if I change the name to shorter one (e.g.,step1_CCEPs_Pre) it runs ok but it's no good for me as i wanna call my code as above.

 Accepted Answer

Guillaume
Guillaume on 9 Oct 2017

1 vote

Matlab only uses the first namelengthmax characters of any identifiers. This has been fixed to 64 characters since forever and there's been no indication that it's about to change.
There is no workaround, you will have to use shorter names. Embedding metadata in filenames is not a good idea anyway. Embed that metadata with your data instead.

1 Comment

namelengthmax is currently 63 characters and has been at 63 characters. The limit on the maximum identifier length was increased from 31 to 63 at the same time the namelengthmax function was introduced, both in MATLAB 6.5 (release R13.) See the Release Notes for that release for more information. Note that viewing this old documentation may require logging in to your MathWorks account.

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 9 Oct 2017

1 vote

In this case the problem is not with the length of the name but with the characters it contains. The names of functions in MATLAB must start with a letter, must be no longer than namelengthmax characters, must not be the same as a keyword (with the exception of an overloaded end method), and must contain only letters, numbers, and the underscore character.
The name step1_preproccessing_CL_TDT-170920-112847 satisfies three of those four requirements. It fails the last; the character '-' is not allowed in function or variable names.

Categories

Community Treasure Hunt

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

Start Hunting!