Creating variable whose name is part of a string
Afficher commentaires plus anciens
I have a .mat file as an input for my function and I know that it contains a struct, but I don't know exactly the name of that struct (is different from file to file).
>> s = load('myFile');
>> name = fieldnames(s)
name =
unknown
where unknown depends on the .mat file input I have.
How can I access s.unknown.X? (I know for sure that unknown have an X and Y field, whatever the input might be)
Réponse acceptée
Plus de réponses (1)
Vishal Rane
le 13 Juin 2013
You could try this:
eval([name, ' = 10'])
1 commentaire
Dina Irofti
le 13 Juin 2013
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!