call a function within a function from the same class in matlab

Here is an example of how to call a function within a function from the same class in matlab:

main.m
classdef MyClass
   methods
      function out = myOuterFunction(obj, in)
         % Call the inner function
         out = obj.myInnerFunction(in);
      end
      
      function out = myInnerFunction(obj, in)
         % Inner function code goes here
         out = in;
      end 
   end
end
294 chars
14 lines

In the above example, myOuterFunction calls myInnerFunction by using obj.myInnerFunction(in). Both functions are defined within the same class MyClass.

related categories

gistlibby LogSnag