Finding the index of duplicate rows in a cell

4 ビュー (過去 30 日間)
NA
NA 2021 年 4 月 20 日
編集済み: Jan 2021 年 4 月 21 日
I have A and B
A = [3,8; 8,9; 8,9; 3,9; 3,9; 3,5; 5,10; 5,10; 3,10; 3,17; 3,17; 11,17; 10,11; 10,11; 3,10];
B = {[3,8;8,9;9,3];[3,5;5,10;3,10];[3,17;3,10;10,11;11,17]};
I want to find indices of all rows in the cell and the repeated rows
I use this code
for i=1:numel(B)
[~,X] = intersect(A,sort(B{i},2),'rows','stable');
index_temp{i} = X;
end
But it does not give me for the repeated rows
Result should be:
index_temp ={[1;2;3;4;5],[6,7,8,9],[10,11,15,13,14,12]}

採用された回答

Jan
Jan 2021 年 4 月 20 日
編集済み: Jan 2021 年 4 月 21 日
A = [3,8; 8,9; 8,9; 3,9; 3,9; 3,5; 5,10; 5,10; 3,10; 3,17; 3,17; 11,17; 10,11; 10,11; 3,10];
B = {[3,8;8,9;9,3]; [3,5;5,10;3,10]; [3,17;3,10;10,11;11,17]};
result = cell(1, numel(B)); % Pre-allocate
for k = 1:numel(B)
X = ismember(A, sort(B{k}, 2), 'rows');
result{k} = find(X);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by