Computer programs are comprised of executed commands. When each command is executed the computer determines the result.
Typically it is helpful for the computer to remember the result by storing it in memory. This way the information can be used throughout the program.
It might be as simple as storing the answer to a basic math equation. Or it might be storing an audio file in memory for processing and mixing with other audio files.
To organize and keep track of the information, the result of an executed command can be assigned to a variable.
After a variable is created and assigned, it can be used in subsequent commands.
When a variable is not explicitly declared in a command, the Matlab programming language will automatically created and assign the result to a variable with the name: ans.
As a programmer, you can create and name your own variables. You can have multiple variables stored in memory at the same time. You can re-use variables multiple times.
A variable provides a name to reference specific data stored in memory. Next, let’s look at the different types of data that can be assigned to variables.