How to select fields of a struct that contains certain string?
Mostrar comentarios más antiguos
I have created a trial table of 1x300 struct with 1 field, and within every struct, there are five fields.
for every struct, there is one string in massage that is either 1 or 2, which indicates the type of the struct.
How can I select the structs that only have 1 in there? Thank you.
the table is attached.
2 comentarios
Matt J
el 7 de Feb. de 2023
Please attach the table in a .mat file.
Matt J
el 7 de Feb. de 2023
It would advisable for you to avoid refering to variables as "tables" unless they really are Matlab table variables.
Respuesta aceptada
Más respuestas (1)
load table
for i=1:numel(trial_table)
s=trial_table(i).trial;
[~,loc]=ismember({'1','2'},{s.message});
result(i)=s(loc(loc~=0));
end
result
1 comentario
JCH
el 7 de Feb. de 2023
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!