Effacer les filtres
Effacer les filtres

Modifying the search path is not supported by Matlab Compiler?

8 vues (au cours des 30 derniers jours)
Aram Zeytunyan
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 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.

Réponse acceptée

Image Analyst
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.

Plus de réponses (2)

Steven Lord
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.

Aram Zeytunyan
Aram Zeytunyan le 23 Avr 2024
Thank you both! Adding the line shown below to the deployment settings worked for me. It basically included all the files from the specified folder, which obviously made the installer package much larger (which is fine). To be honest, I don't understand the statement "Try taking that line of code out of your program." How can it be taken out of the program, if that line is what makes the app to connect to the Moku:Go?
-a 'C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\moku-MATLAB(2)'
  2 commentaires
Image Analyst
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
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by