Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Trim a dataset based on array of subject IDs that correspond to rows to keep in matrix

1 回表示 (過去 30 日間)
Chelsea
Chelsea 2015 年 10 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi,
I have a large matrix, where the first column is subject IDs (around 2000 people). For a particular analysis, I'd only like to look at 800 specific people. I have an array of these subject IDs. Basically, I'd like to compare the list of subject IDs I want to keep to the subject ID column in the matrix. If a subject ID isn't present in the list, I want to delete that subject's entire row from the matrix. I've done logical indexing and for loops for this type of thing on a smaller scale, but can't seem to think of how to do this efficiency on a large scale.
Thank you!

回答 (1 件)

dpb
dpb 2015 年 10 月 2 日
b=a(ismember(a,list),:); % see doc ismember for details

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by