hello,
now i am studying matlab class code
but i have some problem in my code ,also i can not find which points make errors.
there two classes(example1,example2) that have some methods(example1 is construct instance of example2 and call methods from example1)
classdef example1 properties value value1 value2 results end methods function obj = example1(value1,value2) obj.value1 = example2(value1)%construct other class
obj.value2 = example2(value2)%construct other class end function add_2(obj, somevalue)% to activate other class method
example2.add_3(obj.value1,somevalue) % run the other class methods
end endend
and other class
classdef example2 properties value limit end methods function obj = example2(limitvalue) % definition of the secound class
obj.limit = limitvalue obj.value = 0 end end methods (Static) % when i deleted the '(static)' it makes a error, i don't understand why this error apper??
function add_3(obj, addvalue) obj.value = obj.value + addvalue if obj.value > obj.limit %disp(['add max',str(obj)])
disp('over') end end end end
first i assign the first class
test1 = example1(10,10) %first i assign the first class
test1.add_2(3) % assign the secound class value as 3
test1.add_2(3) % assign the updated value to secound class value
% i want to assign 3+3 value in secound property test1.value1.value but still "3"
% how can i fix??
Best Answer