Modifying the search path is not supported by Matlab Compiler?
조회 수: 9 (최근 30일)
이전 댓글 표시
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1677576/image.png)
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
채택된 답변
Image Analyst
2024년 4월 23일
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
추가 답변 (2개)
Steven Lord
2024년 4월 23일
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
Aram Zeytunyan
2024년 4월 23일
댓글 수: 2
Image Analyst
2024년 4월 23일
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
2024년 4월 24일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!