If I have a MATLAB class MyClass with a
classdef MyClass
properties
myArray
end
methods
function update(obj, i)
obj.myArray[i] = i*5;
end
end
and I call the update function with
myClass.update(i)
the myArray object does not 'remember' the updates when i increments and I get left with an empty property. Ie. myArray = []
However if I define the function as follows
classdef MyClass
properties
myArray
end
methods
function out = update(obj, i)
out = i*5;
end
end
and call the update function with
myClass.myArray[i] = update(i)
the updates to the myArray property are remembered. Ie. Ie. myArray = [5, 10, 15, 20, 25]
So what is going on here?...in every other language this would work as expected, it seems like there is some MATLAB specific weird scoping/referencing going on here. Anybody know what's happening?