Effacer les filtres
Effacer les filtres

How to get a specific field from a structure stored in .mat file?

71 vues (au cours des 30 derniers jours)
Sidra Aleem
Sidra Aleem le 8 Mai 2017
Commenté : Tobias Adam le 28 Avr 2022
I have saved my structure in . mat using.
filename = 'D:\我的文档\MATLAB\efe\Database.mat';
save(filename,'Data');
Structure got saved . However when I try to load a specific field then I cannot. I used the following line of code for loading.
S = load(filename,'Data.Images');
But when I click S in work space its empty and I got warning " Warning: Variable 'Data.Images' not found. " I also tried using -struct in save command but it throws error.
The argument to -STRUCT must be the name of a scalar structure variable.
Though It has been saved in .mat file. Below is attached screen shot of.mat file.Kindly guide me how to load Images field from stored structure in .mat file
  1 commentaire
Adam
Adam le 8 Mai 2017
Modifié(e) : Adam le 8 Mai 2017
As far as I am aware you cannot load independent fields of a struct. If you save them as separate variables in the .mat file rather than a struct then you can do this, or you can load the whole struct, extract the field and get rid of the rest of the struct if it is too big.

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 10 Mai 2017
It is not possible to load an individual field from a struct array in MATLAB.
  1 commentaire
Tobias Adam
Tobias Adam le 28 Avr 2022
Thank you very much for the answer :-)
Will it be possible in any moment?

Connectez-vous pour commenter.


KL
KL le 8 Mai 2017
  1 commentaire
Sidra Aleem
Sidra Aleem le 9 Mai 2017
@KL i have visited this link before posting my own question. And I have stated the errors that I am facing by using the solutions in the link you mentioned.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 结构体 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!