フィルターのクリア

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

1 回表示 (過去 30 日間)
Chelsea
Chelsea 2015 年 8 月 31 日
コメント済み: Walter Roberson 2015 年 8 月 31 日
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 件のコメント
Walter Roberson
Walter Roberson 2015 年 8 月 31 日
Is large_matrix a cell array? I am confused about where the "list of matrices" is?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by