Using relative paths in function handles for Matlab compiler
11 views (last 30 days)
Show older comments
Wajahat Kazmi
on 12 Mar 2017
Answered: Chris Volpe
on 19 Apr 2017
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
2 Comments
Geoff Hayes
on 13 Mar 2017
Wajahat - are these files chosen by the user through the GUI or do you really mean the m-files which would be packaged with the executable?
Accepted Answer
More Answers (2)
Steven Lord
on 13 Mar 2017
How are you creating these function handles? If the functions are on the MATLAB search path, neither you nor your program should care where the actual files are located. For instance, the vander function is on the MATLAB path and so this code doesn't care in which directory the actual vander.m is stored.
F = @vander;
F(1:5)
Chris Volpe
on 19 Apr 2017
Try adding:
%#function myfunc
to your code. This comment serves as a hint to the compiler that it should include the specified function in the compiled functions package even if it is not reached during dependency checking.
0 Comments
See Also
Categories
Find more on MATLAB Runtime 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!