How to loop through matrices, pull the nth row of each, and append to new matrix?
1 view (last 30 days)
I am trying to create a for loop that will go through a list of matrices, pull the nth row (e.g., 3rd) from each, and add all of these rows to a new matrix.
for ii = 1:length(list_of_subjs)
subj_num = large_matrix(ii);
subj = large_matrix;
subj = subj(any(subj(:,1)==subj_num,2),:);
for jj = 1
subj_time = subj(jj,:);
subj_t1_items = subj(jj,3:23);
%subj_t1_items(jj) = subj_t1_items;
subj_t1 = [subj(jj,1), subj_t1_items]
subj_t1(ii,:) = subj_t1;
Here, I'm trying to get the first row from each subject (all data contained in large matrix, then I create a matrix for each subject, and try to pull first row from there. For some reason, this just gives me all zeroes and then the data for the last subject (in the last row).