Modifying the search path is not supported by Matlab Compiler?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Aram Zeytunyan
le 23 Avr 2024
Commenté : Steven Lord
le 24 Avr 2024
Trying to create a Matlab app in R2023b. The deployed application should connect to a Moku:Go device (which is using its own Matlab toolbox) and take some measurements. The app is running smoothly when running from Matlab, but giving an error message when running from the deployed standalone app.
I have looked at the following topic: https://www.mathworks.com/matlabcentral/answers/1786755-modifying-the-search-path-is-not-supported-by-matlab-compiler?s_tid=sug_su
I have added the following line in my Matlab startup code and have made sure that all the required Moku files are embedded during the app deployment:
addpath(genpath('C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\moku-MATLAB(2)'))
Please advise what can be done to have the deployed app running.
0 commentaires
Réponse acceptée
Image Analyst
le 23 Avr 2024
Try taking that line of code out of your program. To add files that the compilation process may not see and automatically include you can use the '-a' option of mcc.
0 commentaires
Plus de réponses (2)
Steven Lord
le 23 Avr 2024
See the "Do Not Rely on Changing Directory or Path to Control the Execution of MATLAB Files" section on this documentation page. If you need to add a directory to the MATLAB search path in order for the files it contains to be visible to MATLAB Compiler, do so before trying to create the application rather than inside the application itself. Or use the -a option for mcc as Image Analyst suggested. Also see this documentation page.
0 commentaires
Aram Zeytunyan
le 23 Avr 2024
2 commentaires
Image Analyst
le 23 Avr 2024
You said you have this line in your program:
addpath(genpath('C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\moku-MATLAB(2)'))
remove that line.
Put that '-a' line on the mcc line, either on command line, or in a m-file script that you use to compile and possibly do other things (which is what I do), or use deploytool to use the -a option (which is what you're doing).
Steven Lord
le 24 Avr 2024
Alternately, if you need to add this directory to your path when you're running your application in MATLAB (not as a deployed application), wrap it in:
if ~(ismcc || isdeployed)
end
as the documentation to which I linked showed you.
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!