Matching and adding data from multiple columns between different arrays
이전 댓글 표시
Hello,
I have two matrixes of nx3 (A) and a larger nx7 (B) where B also has more rows. All of the data in A matches data in B, but B also has additional data which I do not need. I want to find where these match i.e. column (A(:,1) == B(:,1) and (A(:,2) == B(:,2) and (A(:,3) == B(:,3). Where these rows match I want to append the data in the extra columns in B (:,4:7) to A. The end result should be a nx7 matrix.
My problem comes from matching three columns in A to data in three columns in B. Trying something like:
I = all(A(:,1)== B(:,1))& all(A(:,2)==B(:,2))& all(A(:,3)==B(:,3));
doesn't work as I get the error "dimensions must agree" - I get the same issue when trying to use intersect, ismember, and setdiff also. I thought I could get around this using logical indexing but so far it hasn't worked.
Is there a way around this?
Many thanks!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!