Python calling Matlab User Function from any directory using matlab module
<p><strong>Background</strong></p>

<p>I'm working with Python 2.7.6 and Matlab 2016a and have installed the official MathWorks Python to Matlab bridge.  It is the matlab and matlab.engine modules.  All of the other questions I've seen on SO regarding matlab/python use third-party wrappers that seem out of date. I have no experience programming in matlab itself, but plenty of python experience.</p>

<p>I'm currently porting this wrapper code from matlab_wrapper to the matlab module: <a href="https://github.com/javiergonzalezh/dpp" rel="nofollow">https://github.com/javiergonzalezh/dpp</a>.  matlab_wrapper did not work for me (gave an undefined symbol in the openssl library that installed with matlab 2016a), hence the port to something that does work and will be maintained for future versions of matlab.</p>

<p><strong>Question</strong></p>

<p>This documentation shows how to call user defined functions (.m files) that are in the current directory.
<a href="http://www.mathworks.com/help/matlab/matlab_external/call-user-script-and-function-from-python.html" rel="nofollow">http://www.mathworks.com/help/matlab/matlab_external/call-user-script-and-function-from-python.html</a></p>

<p>How can I call matlab user functions from any cwd using the matlab module in python?  Is there some kind of OS environment $PATH variable or some matlab equivilent?  If it helps, the .m files reside in the same directory as the calling python code.</p>

<p>Due to the comment by @excaza, I solved this by setting the MATLABPATH environment variable to point to the folder containing my *.m files.</p>

<p><a href="http://www.mathworks.com/help/matlab/matlab_env/add-folders-to-search-path-upon-startup-on-unix-or-macintosh.html" rel="nofollow">http://www.mathworks.com/help/matlab/matlab_env/add-folders-to-search-path-upon-startup-on-unix-or-macintosh.html</a></p>

python matlab path