Hi there, I am new at MATLAB and currently trying to extract data from a particular subfolder and put it into a new cell array
basically i want to retrieve mean reaction times which is stored in a variable called a (location: parent_directory > containing many subject folders labelled img0001, img0002 etc > each subject folder contains a .mat file called stopchoicert.mat > variable a can be found here)
My code is as follows but instead of every iteration being placed into cell array, the values keep getting overwritten so i only have the mean reaction time of my last subject.
I have around 325 subjects but not all of them have mean reaction times, so I am unsure how many values in my cell array I should be getting at the end but the output rt that i get is a 326x1 cell array although only the 80th row contains the mean reaction time (of the last subject) and the rest of the cells are a 0X0 double
parent_directory = dir;
rt = cell(size(parent_directory));
for i = 1:length(parent_directory)
if ~isempty(strfind(parent_directory(i).name,'img'))
foldername = [parent_directory(i).folder '/' parent_directory(i).name];
cd(foldername);
if isempty(dir('stopchoicert.mat'))
continue;
end
load ('stopchoicert.mat')
rt{i,1}= a
end
end
rt
please help and lmk if you need any more info
0 Comments
Sign in to comment.