MATLAB: Does MATLAB use the same memory address for variables that have different names but the same value

copyMATLABonsamevaluevariablewrite

I would like to know if MATLAB uses the same memory address for variables that have different names but the same value. I would also like to know if MATLAB uses "copy-on-write".
For example, if I issue the following commands in the MATLAB Command Window (assuming a is already declared):
b=a;
c=a;
I can do a WHOS and it looks like MATLAB is allocating memory for each variable.

Best Answer

When MATLAB creates a variable, it actually creates two elements of data. One part is the data itself, the other part is a header that contains information about the data (such as where in memory the data lives, how big it is, etc). For more information see the External Interfaces/API Manual which may be found at:
When executing an assignment such as 'b = a', MATLAB creates a new header for 'b', but just tells the data element for 'b' to point to the data element for 'a'. This is done for efficiency. Until there is a definite need to create a separate copy of data for 'b', 'a' and 'b' will share the same data. When the value of the data for 'a' or 'b' changes, MATLAB will make a separate copy of the data for each variable. This is called "copy on write".
The output of WHOS may make it seem like MATLAB is allocating memory for each variable, but this is not always the case. WHOS will show you the memory usage assuming each variable has its own data set.
For example, after entering in 'b=a', any of the commands below will cause MATLAB to allocate new storage space for 'b'.
b(1)=7;
b=2*a;
a(1)=2;
b = b+0;
This feature allows MATLAB to be more efficient, allocating memory only when needed.