How to define a user path in C++

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 Kommentare

Jan
Jan am 22 Mai 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
Jan am 22 Mai 2019
[MOVED from section for answers] Domenico Ferrara wrote
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
Jan am 22 Mai 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?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Gefragt:

am 22 Mai 2019

Kommentiert:

Jan
am 22 Mai 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by