Input argument "c" is undefined, How to pass c to foo2() ? [matlab]

I have the following code:

classdef ClassA

properties
    A;
    B;

end

methods
function obj = ClassA(A,B)

    obj.A = 1;
    obj.B = 2;
    obj.foo1();

end
 function c = foo1(obj,A,B)

    c = obj.A+obj.B;
    obj.foo2()

 end
 function foo2(obj,c,A)
     disp(c);
     disp(obj.A);

 end

end
end

I am trying to get the value of variable c from foo1(obj,A,B), and pass to foo2(obj,c,A), when I do so, I get the following error:

Input argument "c" is undefined.

I tried to solve it by write foo2 in this way:

foo2(c,A)

then I got this:

Undefined variable "obj" or class "obj.A"

I would be grateful if you could help me.


Source: oop

1 Comment

  1. Digin Dominic

    Pass it as an input

    obj.foo2( c )

    Reply

Leave a Reply