I would like to delete rows which contain 'ones' in matrices of different sizes, 'ones' indicate bad steps. I want to make a loop to do this for every matrix of 'Gait information' for all the participants, but is is not working yet. The ones can be present in the first and the sixth column of the matrix.
What does work is this example for 1 particular participant:
A = (DATA(15).GAIT_INFO); % 24x11 double
todelete = (A(:,1) == 1) ;A(todelete,:) = [];todelete_2 = (A(:,6) == 1); A(todelete_2,:) = [];% A has changed to 18 x 11 double which is correct since the original A had 6 rows with ones.
new_Gait_info = A;DATA(15).GAIT_INFO = new_GI;
I tried the following loop:
ii = 3:size(filenames,1) % for all participants, ii = 1 x 35 double. Starting with 3 since for a certain reason the first 2 arrays are empty
for j = 1:length(DATA(ii).GAIT_INFO); todelete = (j(:,1) == 1); j(todelete,:) = []; todelete_2 = (j(:,6) == 1); j(todelete_2,:) = [];end
The error starts at the beginning of the loop j = 1:length(DATA(ii).GAIT_INFO); gives 'Index exceeds array bounds. '
How can I make a loop to check all GAIT.INFO matrices for rows with 'ones' and delete those rows?
Best Answer