Name of deployed app

조회 수: 8 (최근 30일)
Roberto Gentile
Roberto Gentile 2019년 8월 20일
댓글: Anna Weeks 2023년 11월 3일
Hello everyone,
Some months ago I deployed a number of apps using the matlab compiler. I used to add a folder "images" within the "files required to the application to run" and successfully access it by doing:
fullfile(cftroot,'images')
After updating to 2019a, it seems that the folder hierarchy of the app is changed, and the images folder is located in a subfolder
fileName = 'fileName'; % first 12 characters of the name given in the matlab compiler
fullfile(cftroot, fileName, 'images')
My question is simple (I hope):
is there a function that allows me to automatically retrieve "fileName"?
(So that if I change the name of the deployed file, I don't need to change the code)
Thank you very much,
Rob

채택된 답변

Subhadeep Koley
Subhadeep Koley 2019년 8월 23일
MATLAB provides fileparts and mfilename function to get parts of file name and to get file name of currently running code.
Therefore, using the following code in the startupFcn callback of your code might help.
[filepath,name,ext] = fileparts(mfilename('fullpath'));
Here the variable "name" contains the name of the current running file.
  댓글 수: 3
Jiri Hajek
Jiri Hajek 2021년 7월 22일
I'm looking for an answer to the same question, but this one is not really correct. An app name (exe file) may be different from the m-file before compilation. The mfilename function return the name of the original m-file, not of the exe-file.
Any help would be much appreciated...
Anna Weeks
Anna Weeks 2023년 11월 3일
filepath = fileparts(mfilename('fullpath'));
Appname = strtok(filepath(numel(ctfroot)+1:end),'\');

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Application Deployment에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by