Cross-referencing fields in a struct
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a struct called BHV which contains a number of fields. I am interested in four of them.
TrialNumber: [203x1 double] % containing a sequence of trial numbers 1 to 203
ConditionNumber: [203x1 double] % which movie was shown on that trial, 1, 2, 3, 4, 5 or 6
TrialError: [203x1 double] % whether correct (0) or error (1) or aborted (2)
AnalogData: {1x203 cell} % eye movement data for each trial
The following code
n=1:203;
TrialCode = BHV.TrialError(n); % the error code for each trial
Condition = BHV.ConditionNumber(n); % which movie
E1=find(TrialCode==0 & Condition==1);
will create an array with only the TrialNumbers that correspond to error code 0 (correct) and movie 1. I would next like to make a cell array, a subset of AnalogData, that contains just the cells corresponding to those trials in E1. I would be grateful for any helpful suggestions.
댓글 수: 0
답변 (2개)
Nick
2014년 1월 8일
댓글 수: 1
Matt J
2014년 1월 8일
편집: Matt J
2014년 1월 8일
How can I retrieve the EyeSignal fields from these cells?
Retrieve them in what form? Do you want the EyeSignal data from the two different cells concatenated into a 3552x4 array? If so
result = [Movie1Data.EyeSignal]
If that's not it, I think you need to start a fresh thread explaining the data extraction you're trying to do in full and from scratch.
I also recommend you reconsider your data organization. It looks like a nightmare. Structs inside cells inside structs... Among other things, it never makes sense to have a cell array where the cells contain scalar structs with the same fields. That's what struct arrays are for.
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!