Effacer les filtres
Effacer les filtres

How to Call the Name of a Loaded File?

2 vues (au cours des 30 derniers jours)
Rightia Rollmann
Rightia Rollmann le 18 Fév 2017
Modifié(e) : dpb le 18 Fév 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

Réponse acceptée

dpb
dpb le 18 Fév 2017
Modifié(e) : dpb le 18 Fév 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.

Plus de réponses (0)

Catégories

En savoir plus sur Variables dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by