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

1 次查看(过去 30 天)
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!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by