Cross-referencing fields in a struct
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Nick
el 8 de En. de 2014
1 comentario
Matt J
el 8 de En. de 2014
Editada: Matt J
el 8 de En. de 2014
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.
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!