Need to remove elements which repeated 2 times

조회 수: 1 (최근 30일)
NA
NA 2020년 3월 3일
댓글: NA 2020년 3월 3일
I have
A=[1 2; 1,3; 1,4; 1,5; 2,3; 3,6; 4,5; 5,6];
element 2, 4, 6 repeated 2 times. I want to remove them from A.
A_new=[1,3; 1,5]
  댓글 수: 5
Turlough Hughes
Turlough Hughes 2020년 3월 3일
If you have values repeated in the same row and nowhere else, is that row to be deleted also?
i.e. for this input
A=[1 2; 1,3; 1,4; 1,5; 2,3; 3,6; 4,5; 5,6; 8 8];
is then answer then
A_new = [1 3; 1 5; 8 8]; %or
A_new = [1 3; 1 5];
NA
NA 2020년 3월 3일
in my case should be A_new = [1 3; 1 5];

댓글을 달려면 로그인하십시오.

채택된 답변

Alex Mcaulley
Alex Mcaulley 2020년 3월 3일
A=[1 2; 1,3; 1,4; 1,5; 2,3; 3,6; 4,5; 5,6];
N=max(max(A));
A_new = A;
for i=1:N
if sum(sum(A==i),2)==2
A_new(any(ismember(A_new,i),2),:)=[];
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by