Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One suggestion, which would avoid having to modify the <a href="http://www.mathworks.com/help/techdoc/ref/path.html" rel="nofollow noreferrer">MATLAB path</a>, is to use a <a href="http://www.mathworks.com/help/matlab/matlab_prog/private-functions.html" rel="nofollow noreferrer">private function directory</a>. For example:</p> <p>Let's say you have a function called <code>test.m</code> in the directory <code>\MATLAB\temp\</code> (which is already on the MATLAB path). If there are local functions in <code>test.m</code> that you want to place in their own m-files, and you only want <code>test.m</code> to have access to them, you would first create a subdirectory in <code>\MATLAB\temp\</code> called <code>private</code>. Then, put the individual local function m-files from <code>test.m</code> in this <code>private</code> subdirectory.</p> <p>The <code>private</code> subdirectory doesn't need to be added to the MATLAB path (in fact, it <em>shouldn't</em> be added to the path for things to work properly). Only the file <code>test.m</code> and other m-files in the directory immediately above the <code>private</code> subdirectory have access to the functions it contains. Using private functions, you can effectively emulate the behavior of <a href="http://www.mathworks.com/help/matlab/matlab_prog/local-functions.html" rel="nofollow noreferrer">local functions</a> (i.e. limited scope, function overloading, etc.) without having to put all the functions in the same m-file (which can get very big for some applications).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload