extracting field name and values from a struct.

55 visualizaciones (últimos 30 días)
Matthew Wilson
Matthew Wilson el 2 de Nov. de 2018
Editada: MFK el 16 de En. de 2023
Hi all,
I have files produced by a piece of research equipment and each file comes up as 1x1 struct with 65 fields. I am interested in getting the field name and corresponding values from only six of these, each field is named and not numbered.
Is there a way of getting Matlab to provide just the filenames and values of the six I am after?
Thanks!
MJ

Respuestas (2)

madhan ravi
madhan ravi el 2 de Nov. de 2018
See getfield() might be the one you’re looking for.

MFK
MFK el 16 de En. de 2023
Editada: MFK el 16 de En. de 2023
fn=fieldnames(out);
for jj=1:size(fieldnames(YOUR_STRUCT),1)
features1(1,jj)=YOUR_STRUCT.(fn{jj});
end

Categorías

Más información sobre Structures en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by