How can I do loop for struct data?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
Azzi Abdelmalek
2016년 4월 18일
a=struct('f',num2cell(1:10))
out=[a.f]
댓글 수: 6
Riyadh Muttaleb
2016년 4월 18일
편집: Riyadh Muttaleb
2016년 4월 18일
Azzi Abdelmalek
2016년 4월 18일
Post an example
Azzi Abdelmalek
2016년 4월 18일
v=num2cell(rand(4))
a=struct('f',v)
%-------------------------
out=reshape([a.f],size(a))
Riyadh Muttaleb
2016년 4월 20일
Azzi Abdelmalek
2016년 4월 20일
suppose you have this matrix
A=[1 2;3 4;5 6]
What operation you want to apply?
Riyadh Muttaleb
2016년 4월 21일
Walter Roberson
2016년 4월 19일
Example:
arrayfun(@(IDX) mean(YourStructArray(IDX).TheField(:)), 1:numel(YourStructArray))
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!