MATLAB: Using relative paths in function handles for Matlab compiler

file pathfunction handlerelative path

Hi I am generating a deployable exe using Matlab Compiler (mcc). My code includes certain function handles whose files, in the target PCs, will be at different locations than the PC they were generated on. Matlab compiler generates an exe, successfully. However, it looks for the absolute paths of the files for the corresponding function handles.
I would be grateful, if someone can tell me:
1- How can I use relative paths in the function handles (since the .m files for the functions will be at a fixed relative location w.r.t the exe file but different absolute location on the target PCs)?
2- If I cannot, what is the best possible work around?
Best Regards Wajahat

Best Answer

Hi
Seems like it is solved by using mcc with -a option followed by filename with path to the file containing function definition.
mcc -m -o MyExecFilename MyCode.m -I LibrariesToInclude -a LibrariesToInclude/FuncDefs/myFunc.m
So, even if the files are there in the path, function definitions whose function handles are being used, need to be explicitly added at the compile time.
Best Regards
Wajahat