How to define a user path in C++
Show older comments
Dear support
I call matlab scripts in a C++ application using the generic interface and that works quite well.
But, if my main script (main.m) locate in the folder A calls a function (foo) defined in foo.m, and located in folder B, then I got an error such as
Undefined function or variable 'foo'.
I tried to define the environemnt variable MATLABPATH and also to modify pathdef.m, without success .
Is there a way to tell Matalb where to look for user's function ?
Thanks for your help
Best Regards
Domenico
3 Comments
Jan
on 22 May 2019
From where did you modify which pathdef.m file? There can be one in the user's working directory and one inside Matlab's installation folder.
The run command let you specify a folder also on demand.
Jan
on 22 May 2019
Hi Jan
I modify pathdef.m from the Matlab application , using the setPath icon.
There is a copy of pathdef.m in my user's directory (/home/$USER, I am on Ubuntu 18.04) and also in my working directory.
When I start matlab and run the script from matlab, everything is going fine.
When I use the C++ generic interfaces (generated from mcc) and call the m file from a C++ application (using feval(...)), I got a crash (undefined function or variable 'XXXX')
Jan
on 22 May 2019
Please post comments in the section for comments.
Which pathdef.m file is used in your case? Is the "B" folder included there or not? Is the "B" folder included, when you create a stand-alone application?
Answers (0)
Categories
Find more on Deploy to C++ Applications Using mwArray API (C++03) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!