Azzera filtri
Azzera filtri

How to Call the Name of a Loaded File?

2 visualizzazioni (ultimi 30 giorni)
Rightia Rollmann
Rightia Rollmann il 18 Feb 2017
Modificato: dpb il 18 Feb 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

Risposta accettata

dpb
dpb il 18 Feb 2017
Modificato: dpb il 18 Feb 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.

Più risposte (0)

Categorie

Scopri di più su Variables 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!

Translated by