Borrar filtros
Borrar filtros

mfilename is not working for me

7 visualizaciones (últimos 30 días)
Sudharsan
Sudharsan el 4 de En. de 2013
I am trying to get the file name of the lastly invoked mfile using the following command.
a=mfilename('fullpath')
but workspace is returning null. http://i46.tinypic.com/309hk4o.jpg
Can anyone tell me where i am committing mistake.!!
I'm working on MATLAB Version 7.13.0.564 (R2011b)

Respuestas (3)

Andreas Goser
Andreas Goser el 4 de En. de 2013
The documentation says: "When called from the command line, mfilename returns an empty string."
  1 comentario
Jan
Jan el 4 de En. de 2013
@Sudharsan: This means, that your expectations are the mistake. What do you want to obtain in the command line?

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 4 de En. de 2013
mfilename only works inside the script when it's running. I don't know that that information on the last m-file that was run is kept, or if it is, if it's available for you to easily get. Maybe it's kept somewhere, though I don't know where. You might try poking around http://undocumentedmatlab.com/

Sean de Wolski
Sean de Wolski el 4 de En. de 2013
Might be able to get it from the command history:
com.mathworks.mlservices.MLCommandHistoryServices.getSessionHistory

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by