Cross-referencing fields in a struct
2 次查看(过去 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 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!