So I have a cell array of vectors X:
octave:149> X X = { [1,1] = 1 17 20 [2,1] = 5 20 22 27 [3,1] = 2 17 18 21 } I create an empty vector Y:
octave:150> Y = [] Y = [](0x0) I then call an anonymous function on each value of X with "Y = unique([Y x])":
octave:151> cellfun(@(x)(Y = unique([Y x])),X,'UniformOutput',false) ans = { [1,1] = 1 17 20 [2,1] = 1 5 17 20 22 27 [3,1] = 1 2 5 17 18 20 21 22 27 } Ok, but now Y is still empty:
octave:152> Y Y = [](0x0) octave:153> Clearly the Y name inside the anonymous function created and bound a new storage for its own version of Y.
What are the storage and name resolution rules in Octave/MATLAB? When is storage allocated for a variable? When are two identical names bound to the same variable? (Is there any way to effect the value of Y in the above anonymous function?)