MATLAB Answers


Name of deployed app

Asked by Roberto Gentile on 20 Aug 2019
Latest activity Commented on by Roberto Gentile on 25 Aug 2019
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:
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,


Sign in to comment.




1 Answer

Answer by Subhadeep Koley on 23 Aug 2019
 Accepted Answer

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.

  1 Comment

Thank you!
very much appreciated!

Sign in to comment.