How to read specific fields from multiple structure arrays in MATLAB?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I have a very large dataset arranged into multiple structure arrays in MATLAB. The structures look something like this:
Flight1=
.testpoint = 1
.Mach = 0.8
.Speed = 300
.Cieling = 35000
.Data = [A] % A is an MxN matrix
Similarly there are multiple test points for multiple flights. Is there a way to retrieve the Data of only specified test points? For example I want to plot and compare the Data of ALL the test points whose .Mach = 0.8 or where .testpoint = 2?
I hope I have made it clear enough.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 2월 20일
편집: Azzi Abdelmalek
2013년 2월 20일
idx=cellfun(@(x,y) x==2 |y==0.8,{Flight1.testpoint},{Flight1.match})
%idx is the index that fit your conditions
댓글 수: 6
Azzi Abdelmalek
2013년 2월 20일
편집: Azzi Abdelmalek
2013년 2월 20일
for k=1:10
s=sprintf('Flight%d',k)
Flight1=load(s)
idx=cellfun(@(x,y) x==2 |y==0.8,{Flight1.testpoint},{Flight1.match})
out=Flight1(idx)
v{k}={out.testpoint}
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!