I have a huge value class. Because I'm afraid of further problems, I don't want it to be a HandleClass by now.
Anyway, I want to change a class property from a class method. Is this possible under any circumstances? I made an example and modifyValue is the critical function:
testClass.m:
classdef testClass properties a end methods function obj = testClass() obj.a = [1 2 3; 4 5 6]; end function obj = modifyValue(obj) obj(:,2) = []; % won't work as well
obj.a(:,2) = []; end end end
subsasgn.m:
function obj = subsasgn(obj, S, value) if isempty(value) obj.a(:,S.subs{2}) = []; else obj = builtin('subsasgn',obj, S, value); end end
Why isn't it possible to call obj(:,2) = []; from within the object? This confuses me. I'm still using Matlab R2007b, but solutions for newer versions are also very welcome.
Best Answer