Borrar filtros
Borrar filtros

How to Call the Name of a Loaded File?

2 visualizaciones (últimos 30 días)
Rightia Rollmann
Rightia Rollmann el 18 de Feb. de 2017
Editada: dpb el 18 de Feb. de 2017
I load B which is a struct as follows:
A = load( ‘B.mat’ );
How can I later access the name of file B from A? When I call A, I only get the name of all fields, but not the name of the MAT File B

Respuesta aceptada

dpb
dpb el 18 de Feb. de 2017
Editada: dpb el 18 de Feb. de 2017
"From A", you can't; the data stored in a .mat file are totally independent of the (root) name given the file when it was created. The only way to create a connection would be to add another variable or field in the structure that contains the filename you're going to use when SAVE the data. Of course, this runs the risk you don't update the field correctly or at all, so it's not a sure-fire method, either.
What's the problem you're actually trying to solve? If you have 'b.mat' to load the file, what's to keep from creating the link from that information to do whatever it is that you wish to do?
But the upshot is, there is nothing within a standard .mat file than the variables written to it; if you don't add information within the file if the filename that was used to load it is somehow lost it can't be told which file it was.

Más respuestas (0)

Categorías

Más información sobre Variables 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