<html lang="en"> <head> <title>Private Functions - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Function-Files.html#Function-Files" title="Function Files"> <link rel="prev" href="Subfunctions.html#Subfunctions" title="Subfunctions"> <link rel="next" href="Overloading-and-Autoloading.html#Overloading-and-Autoloading" title="Overloading and Autoloading"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Private-Functions"></a> <p> Next: <a rel="next" accesskey="n" href="Overloading-and-Autoloading.html#Overloading-and-Autoloading">Overloading and Autoloading</a>, Previous: <a rel="previous" accesskey="p" href="Subfunctions.html#Subfunctions">Subfunctions</a>, Up: <a rel="up" accesskey="u" href="Function-Files.html#Function-Files">Function Files</a> <hr> </div> <h4 class="subsection">11.7.3 Private Functions</h4> <p>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. <p>As a simple example, consider a function <code>func1</code>, that calls a helper function <code>func2</code> to do much of the work. For example <pre class="example"> function y = func1 (x) y = func2 (x); endfunction </pre> <p class="noindent">Then if the path to <code>func1</code> is <code><directory>/func1.m</code>, and if <code>func2</code> is found in the directory <code><directory>/private/func2.m</code>, then <code>func2</code> is only available for use of the functions, like <code>func1</code>, that are found in <code><directory></code>. </body></html>