I have a global array of values which will be operated on by a set of objects. Each of my objects operate on subsets of this global array by using its values and possibly changing them. I want these changes to be reflected in all instances of the array elements. For example, if globalArray(5:8) is referenced by objA.data(2:5) and objB.data(3:9), a change in objA.data(3) should automatically be reflected in globalArray(6) and objB.data(4). In Python, I would declare this array as a Numpy ndarray, and have my objects operate on its slices, as the slices are pointers/views into this array. In MATLAB, could this functionality be replicated by declaring this array as a global variable? Are there any differences between this implementation in the two languages?
I've looked at the accepted answer given here :https://uk.mathworks.com/matlabcentral/answers/109304-passing-matrix-using-call-by-reference but I don't see how I can take pointer slices as the actual array is still a value type.
Best Answer