I'm trying to work with OOP concepts in MATLAB but run into the following problem: I have a number of coefficients which need to be computed, based on some public properties inside a private class method. However, these properties are not set for some reason I don't quite understand. The method I have defined as:
methods (Access = private) function obj = calcSchemeCoefficients (obj) obj.lambda2 = (obj.gamma2*obj.k^2)/obj.h^2; obj.mu = (obj.kappa*obj.k)/obj.h^2; obj.mu2 = obj.mu^2; obj.zeta = (4*obj.b2*obj.mu)/obj.kappa; obj.den = 1+obj.b1*obj.k; obj.a10 = (2-2*obj.lambda2-6*obj.mu2-obj.zeta)/obj.den; obj.a11 = (obj.lambda2+4*obj.mu2+0.5*obj.zeta)/obj.den; obj.a12 = -obj.mu2/obj.den; obj.a20 = (-1+obj.zeta+obj.b1*obj.k)/obj.den; obj.a21 = (-0.5*obj.zeta)/obj.den; % this prints the correct result
fprintf('\nlambda2: %f\n', obj.lambda2); end end
However when I try to recall the property lambda2 for use in another (public) function, it doesn't seem to contain any value… I suspect I am missing some logic here, but I really have no clue what it could be.
Any help on this would be greatly appreciated
Best Answer