How to loop through matrices, pull the nth row of each, and append to new matrix?

2 Ansichten (letzte 30 Tage)
Hello,
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]
end
subj_t1(ii,:) = subj_t1;
end
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).
Thank you!

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by