I have a bunch of reaction time data (scalar) from subjects and am trying to figure out how best to vectorize my code. I have N subjects, each has Y conditions, and the number of values are different between subjects and between conditions. Also the maximum number of entries is unknown. My script loops through each subject, loading their data and searching for particular conditions and saving it. And I don't know how maThus, I can't simply have a matrix that is NxY .
The first thing I thought of is to put them all in a structure A with the conditions as different fields:
A(1:n).condition1
A(1:n).condition2
etc
But there are two problems: 1) I can't iterate through the fields, which is efficient and what I want to achieve, and 2) I can't easily obtain the average reaction times per condition from each subject. I would like to call mean(A(:).condition1) and have it output a 1xN array of the averages but it doesn't work that way.
What is the best way to contain data of variable length such that I can loop through to perform functions on the data? Thank you!
Best Answer