MATLAB: Identity for a matrix cell

MATLABmatrix

Hello,
I would like to create an identity for a matrix cell
Something like:
x=A{2,1}
so that I can access A{2,1} with x
>> x=A{2,1}
x =
5
A{2,1} =
5
further on x is supposed to change continiously
x=x{2,1} is A{2,1}{2,1}
x=x{2,1} is A{2,1}{2,1}{2,1}
and so on
is that somehow possible

Best Answer

That type of variable is called a reference. It is not available in matlab, so no it's not possible.
You could emulate it after a fashion with a class but the syntax would be awkward. The interface would have to be something like:
x = cellreference('A', 2, 1); %create reference to cell {2, 1} of A
x.set(5); %set value of referenced cell to 5
x.get; %get value of referenced cell
Under the hood, it would have to use evalin or similar. It's not going to be fast.