How to use addpath in compiled matlab code

조회 수: 15 (최근 30일)
Gabriele Jost
Gabriele Jost 2016년 11월 29일
이동: Stefanie Schwarz 2023년 7월 19일
I am trying to create an executable out of a simple matlab code. It uses "addpath" to refer to files in a different directory. During execution This yields an error of this and the message below.
This is typically caused by calls to ADDPATH in your startup.m or matlabrc.m files. Please see the compiler documentation and use the ISDEPLOYED function to ensure ADDPATH commands are not executed by deployed applications.
If I enclose the addpath with an ~isdeployed guard, then the routine is not found at runtime. Can you tell me what I do wrong?
Thanks and best regards,
Gabriele
This is how I use the isdeployed:
if ~isdeployed
addpath <mypath>/test/ECCO2PlotCode
end
nx=4320; % llc face dimension
kx=90; % number of vertical levels
'step2' % plot test U
j1=1
j2=1
for jj=(j1+50):(j2+50)
for i=0:1:24
jj, i
ts=10368+144*24*(jj-1)+i*144;
myint2str(ts,10)
end %for i=0:1:24
clear U V;
end %for jj=1:392

채택된 답변

Image Analyst
Image Analyst 2016년 11월 30일
I see no reason why that code would even need addpath(). If it's just because you need to run myint2str(), don't worry about it. The compiler will find it for you.
If you want to load and save files to a particular folder, then just construct the full filename and use that rather than saving and loading from the current directory or to/from some folder on the search path.
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 11월 30일
이동: Stefanie Schwarz 2023년 7월 19일
The addpath is not needed. Do the addpath first before you compile.
If you have path conflicts, the same routine in multiple locations, distinguished by manipulating the path, then that would be a problem.
Image Analyst
Image Analyst 2016년 11월 30일
이동: Stefanie Schwarz 2023년 7월 19일
Well now you have two of us saying it's not needed. If you still insist, possibly to enable bad programming practices later in your program, then you can put addpath in yourstartup.m file like the error message said.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Gabriele Jost
Gabriele Jost 2016년 11월 30일
Using the GUI and doing the addpath before compilation helped for my small test case. Many thanks for the help and useful information.

카테고리

Help CenterFile Exchange에서 Standalone Applications에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by