Comparing arrays and getting the index of extra rows
조회 수: 1 (최근 30일)
이전 댓글 표시
There are two arrays: A with 8916x3 and B with 6571x3. Each 1x3 set represents xyz coordinates. Array A has some extra coordinates/rows.
I want to compare xyz row by row, and return the index of rows in A that do not exist in B. Then use this index to remove the corresponding extra data from array C (basically C is 8916x3 and it has to be 6571x3 same as B, while keeping the order of rows).
Here's my code but I ge this error: "too many outputs"
[logic,index] =not(ismember(A,B,'rows'))
C(index,:) = [];
댓글 수: 0
채택된 답변
DGM
2021년 11월 2일
Consider:
% example arrays
B = randi(99,5,3)
A = [B; randi(99,3,3)];
A = A(randperm(size(A,1)),:)
% i'm assuming C is some separate array?
C = rand(size(A))
% extract rows from C where A is a member of B, preserving order
C = C(ismember(A,B,'rows'),:)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!