In matlab variables are saved in workspace all through matlab session. While manipulating data at the command line, the variable are stored in base workspace. Variables in workspace can be displayed using whos command. In matlab characteristic has their personal workspace, become independent from matlab workspace.

A Matlab variable is basically which you will assign a value while that value stays in memory. Where the value which was available in the memory so that you can read the programs and operates it on different types of data, and stores back it into memory.

Basically their three types of variables in matlab:

Local Variable:

 A local variable which is described with inside the function. It can only used inside the block code in which it is declared. The local variable exists till the block of the function is below execution. After that, it will be destroyed automatically.

Global Variable:

       A global variable is a program defined outside the function. The scope of global variable, it holds the value through the lifetime of the stores fixed value decided by the complier. Example of global variable:

Function setGlobalx (val)

   global x



Persistence Variable:

Persistent variables can be used inside a simplest function only. Persistent variables stay in memory till the M-document is cleared or changed. Persistent is precisely like global, besides that the variable name is not in the global workspace, and the value is reset if the M-document is changed or cleared.

Both the global and local variable are more significant in programming, global variable occupy large memory because of large amount of variables. Therefore, it is beneficial to avoid declaring undesirable global variables.