which(mfilename) in compiled matlab code returns empty string

Hi,
I have a script that runs perfectly if it is not compiled. I have to read a couple of config files. To get the directory of the current script, I use e.g.
which(mfilename)
and subsequently manipulate the string to get the location of the config files. This works perfectly well, if the script is not deployed. If it is deployed, I get merely an empty string. Is there any alternative? I currently use the MCR version 7.11. If find this odd. Shouldn't it return the location of the executable? Your input is very much appreciated.
Thank you.

 채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 24일

0 개 추천

You should probably be checking isdeployed() and if so use ctfroot()
Note: if you add the configuration files to the executable using the mbuild "-a" flag then imread() and load() against the name without any directory will look first in the ctfroot

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

질문:

2014년 3월 24일

댓글:

2014년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by