How can I do loop for struct data?
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
I have a data set that consist of a structure , example: data (1x10 struct with 1 field) How can I do loop to read all these data? I want to be able to do a calculation on a specific measurements of each field. Thanks
Respuestas (2)
Azzi Abdelmalek
el 18 de Abr. de 2016
a=struct('f',num2cell(1:10))
out=[a.f]
6 comentarios
Riyadh Muttaleb
el 18 de Abr. de 2016
Editada: Riyadh Muttaleb
el 18 de Abr. de 2016
Azzi Abdelmalek
el 18 de Abr. de 2016
Post an example
Azzi Abdelmalek
el 18 de Abr. de 2016
v=num2cell(rand(4))
a=struct('f',v)
%-------------------------
out=reshape([a.f],size(a))
Riyadh Muttaleb
el 20 de Abr. de 2016
Azzi Abdelmalek
el 20 de Abr. de 2016
suppose you have this matrix
A=[1 2;3 4;5 6]
What operation you want to apply?
Riyadh Muttaleb
el 21 de Abr. de 2016
Walter Roberson
el 19 de Abr. de 2016
Example:
arrayfun(@(IDX) mean(YourStructArray(IDX).TheField(:)), 1:numel(YourStructArray))
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!