Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Chelsea
Chelsea le 31 Août 2015
Commenté : Walter Roberson le 31 Août 2015
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!
  1 commentaire
Walter Roberson
Walter Roberson le 31 Août 2015
Is large_matrix a cell array? I am confused about where the "list of matrices" is?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by