There is no way to change an object of a value class on method call, other than to return the updated object as a result, and assign it to the variable that held the old object.
This is a strength. One of the core features of MATLAB is its call-by-value semantics: with non-oop MATLAB you can never, for example, accidentally change the value of an array in one part of a program by an assignment to one of its elements in some remote part of the program. Bugs caused by such actions are one of the biggest problems, especially for beginners, in call-by-reference languages. By sticking to call-by-value, MATLAB must have saved countless thousands of hours of debugging time over the years.
However, handle classes break this, which in the context of MATLAB's normal programming model is dangerous. Therefore handle classes should, in my view, only be used when there is an overriding reason. One possible reason is to represent a unique object; another is to implement certain data structures which can only be efficiently updated with handle-class semantics.
Best Answer