Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
extracting columns with comparison
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
Given I would have (as a toy example) a matrix A like:
A = [ 5 7 -5; 3 8 3; 2 9 2]
I would want to extract the indices of the pairs of columns which have the same y and z values but a negative x value of each other. So for the example this is true for the first and third column (the x values are 5 and -5 respectively, and the y value is 3 for both and the z value is 2 for both too). How would I do that?
댓글 수: 0
답변 (1개)
Andrei Bobrov
2014년 6월 25일
편집: Andrei Bobrov
2014년 6월 25일
B = A;
B(1,:) = abs(B(1,:));
[a,~,c] = unique(B.','rows');
out = [accumarray(c,(1:numel(c))',[],@(x){x})';num2cell(a',1)];
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!