Next: Nested Functions, Previous: Subfunctions, Up: Function Files [Contents][Index]
In many cases one function needs to access one or more helper functions. If the helper function is limited to the scope of a single function, then subfunctions as discussed above might be used. However, if a single helper function is used by more than one function, then this is no longer possible. In this case the helper functions might be placed in a subdirectory, called "private", of the directory in which the functions needing access to this helper function are found.
As a simple example, consider a function func1
, that calls a helper
function func2
to do much of the work. For example:
function y = func1 (x) y = func2 (x); endfunction
Then if the path to func1
is <directory>/func1.m
, and if
func2
is found in the directory <directory>/private/func2.m
,
then func2
is only available for use of the functions, like
func1
, that are found in <directory>
.