필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

extracting columns with comparison

조회 수: 1 (최근 30일)
MiauMiau
MiauMiau 2014년 6월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
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?

답변 (1개)

Andrei Bobrov
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)];

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by