mfilename not working on Live Editor?
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jaime López
il 20 Ott 2017
Commentato: Bradley Stiritz
il 6 Ott 2022
Hi. I'm using matlab 2016a. Inside a Live Editor script, I'm trying to get the script name, using the function mfilename, without any parameters, to get it. What matlab gives as an output is: MatlabEvaluationHelper.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168502/image.png)
I've tried to export this code to a classic matlab .m file, and seems to work fine. Any idea on what could be the problem? Thanks in advance
0 Commenti
Risposta accettata
Cam Salzberger
il 20 Ott 2017
Hello Jaime,
I am afraid that mfilename does not function inside live scripts or functions. Our developers are aware of this feature request, and are considering possible resolutions for future releases of MATLAB.
Can you describe what you are trying to accomplish with "mfilename"? There may be other ways to get a similar workflow to what you desire.
-Cam
12 Commenti
Ornit
il 21 Lug 2022
mfilename still does not work properly in live editor, R2022a. Returns some location on my C drive (while the script is in fact running on a network drive).
However, Jan Kappen idea (filePath = matlab.desktop.editor.getActiveFilename; from 13 Jan 2022) works perfectly. Thanks!
Bradley Stiritz
il 6 Ott 2022
Thank you Jan Kappen for the workaround! and thanks Omit for the +1
After 5 years, it would be nice if the mfilename doc page could be updated to mention the limitation and workaround.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!