How to get values out of an unknown structure array inside a *.mat file?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have many *.mat files, each of them stores a structure array. I am trying to use the below commands to get the values out of their structure arrays:
File = 'a.mat';
b=whos(matfile(File));
Below are the results of 'b' on my command window. In this example, I know S1103 is the name of the structure array. I can use S1103{1} to get the data values I want. But I have many *.mat files with unknown structure array names. How do I get their values. I tried to use b.name{i}, which does not seem to work.
name: 'S1103'
size: [1 16384]
bytes: 49138764
class: 'cell'
global: 0
sparse: 0
complex: 0
nesting: [1x1 struct]
persistent: 0
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 27 Nov 2013
data=load('filename')
variables=fields(data)
5 commentaires
Larry B
le 12 Avr 2018
I was interested in accessing the stored data in .mat file where I do not know the variables. Above answer displayed the variable, but I still could not access the data associated with that file. Old MATLAB had a variable editor, but my 2018a version does not appear to have it in the same form as say 2012b. To access the data, I clicked on the "filename.mat" file, which placed it in the window in the lower lefthand corner. Next executed "Load(filename.mat)" and then execute "openvar(filename.mat)," which opened a variable editor with all the variables listed in a file form. I then clicked on the variables and got access to the stored data.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!