Rules on Variable and Function Names
- Variable/Function name
- begins with a LETTER, e.g., A2z.
- can be a mix of letters, digits, and underscores
(e.g., vector_A, but not vector-A (since "-" is a reserved char).
- is case sensitive, e.g., NAME, Name, name are 3 distinct variables.
- must not be longer than 31 characters.
- Suggestion: Since MATLAB distinguishes one function from
the next by their file names, name files the same as function
names to avoid confusion. Use only lowercase letter to be
consistent with MATLAB's convention.
- File name
- Files that contain MATLAB commands should be named with a
suffix of ".m", e.g.,
something.m.
These include, but not restricted to, script
m-files and function m-files. (See "Files Types"
for details)
- Note: To use it, just refer to it by name, without the suffix,
e.g.,
>> something