From: Ahmad on 28 Jun 2010 14:24 I was wondering how can I replace all object properties with ones retrieved from a file. Lets say I have the following class: classdef Test %TEST Summary of this class goes here % Detailed explanation goes here properties a; b; c; end methods function obj = Test( val_a, val_b, val_c ) obj.a = val_a; obj.b = val_b; obj.c = val_c; end function saveVars( obj ) new_obj = obj; save('test.mat', 'new_obj'); end function replaceVars( obj, value ) % This doesn't work as intended if value > obj.a; load('test.mat'); obj = new_obj; end end end end ------------ Look at the replaceVars() function. I want to load the previously saved object on a certain condition, and then replace the current object with the loaded object's properties. But after calling replaceVars, no properties of the called object change? I think I'm missing a key thought behind MATLAB OOP. Can anyone help me out? thanks,
|
Pages: 1 Prev: CURVE DEFORMATION from curve 1 to curve 2 at various time Next: replace object properties |