Search code examples
matlabclassoopoutputfriend-function

Friend functions in Matlab


I'm working in Matlab using OOP phenomena, However I want a phenomena of friend function like in C/C++ i.e to pass one function's output to other in the same class just for its use. Here, myClass is my class, in which, an output of myFunc1 is required by myFunc2, How can I make these two functions a friend. Is there any facility like other languages?

My Code:

classdef myClass
    properties (Access=private)
        M;
      T
    end
    methods
        function obj = myClass(M,T)
            obj.M= M;
            obj.T=T;

        end
        function H=myFunc1(obj)
            obj.M{obj.jj}=jj+ii;
           H=obj.M{obj.jj};
        end

        function myFunc2(obj)
            obj.T= H;
        end
    end
end

Solution

  • The output of one class-member function to other is simple call that function and collect output in that function, the code:

    function myFunc2(obj)
          H=myFunc1(obj);
          obj.T= H;
    end