I don't think the code you've done does what you think it does.
Octave\Matlab do not implement the concept of pointers in its full meaning.
As beaker said, the assignment operation is copying, so P = T
is another cell array. Actually, for performance reasons it remains the same array until you change contents of one of them. i.e. until P{2}={}
at which point T={}
and P={[1,1] = [](0x0) [1,2] = {}(0x0)}
. (The P = P{2}
doesn't even work by the way.)
That is okay, since Octave\Matlab do not intend to expose memory addressing and such. i.e. you cannot determine whether variables P
and T
are stored at the same address. The equality operator works with elements of arrays and does not work completely for cells.
Octave\Matlab are designed for number crunching.
Easy creation manipulation arbitrary datastructures is outside of their scope.
For creation of lists the following link might be of help, albeit the solution is pretty complex:
MATLAB linked list