diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 374e25584..7e35b0d2b 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -191,7 +191,10 @@ void Module::matlab_code(const string& toolboxPath, if (verbose_) cerr << "generating " << makeFile << endl; emit_header_comment(ofs,"%"); ofs << "echo on" << endl << endl; - ofs << "toolboxpath = pwd" << endl; + ofs << "toolboxpath = mfilename('fullpath');" << endl; + ofs << "delims = find(toolboxpath == '/');" << endl; + ofs << "toolboxpath = toolboxpath(1:(delims(end)-1));" << endl; + ofs << "clear delims" << endl; ofs << "addpath(toolboxpath);" << endl << endl; // generate proxy classes and wrappers