When naming variables as a programmer, there are several rules which must be followed and several “best practices” which should be followed.

 

The Matlab programming language has several restrictions for how variables can be named. Variable names may be individual text characters or multiple text characters. Variable names may contain numbers, but may not begin with a number. Variable names may not contain spaces. Variable names may not contain symbols such as: #, $, %, &, etc.

 

 

There are several recommendations worth using when naming variables. Use a variable name with a descriptive meaning whenever possible. Think about the purpose of the variable and for what it will be used when determining a name. This will make your code easier to read, especially if you are having to review it months or years later.

 

Many programmers across many programming languages use a convention of character capitalization called: camel case. Here, the first character in the variable name is lowercase. Subsequent words or phrases in the variable name begin with a capitalization.

 

Examples of variable names following this convention are: inputSignal, totalTime, numOfSamples, samplingRate.

Receive Updates

No spam guarantee.