필터 지우기
필터 지우기

Remove the duplicated vector in the array

조회 수: 2 (최근 30일)
Sounghwan Hwang
Sounghwan Hwang 2022년 6월 13일
댓글: Voss 2022년 6월 13일
Hi. I'm struggling with how to make my code.
Here is the thing. I want to get a new matrix A such that all duplicated vectors are removed. Here is my matrix A and a new matrix A that I want to get:
A = [1 3; 1 4; 1 3; 1 4; 2 3; 3 4; 3 4; 3 5; 4 5]
new A = [1 3; 1 4; 2 3; 3 4; 3 5; 4 5].
How to write the code to get new A...? I'm trying to make it as a function, however, I don't have clear ideas...
I need some help! Thank you so much!!

채택된 답변

Voss
Voss 2022년 6월 13일
편집: Voss 2022년 6월 13일
A = [1 3; 1 4; 1 3; 1 4; 2 3; 3 4; 3 4; 3 5; 4 5];
new_A = unique(A,'rows')
new_A = 6×2
1 3 1 4 2 3 3 4 3 5 4 5
  댓글 수: 2
Sounghwan Hwang
Sounghwan Hwang 2022년 6월 13일
Awesome.... thank you so much. I didn't know that there is a unique function in the Matlab. Really appreciated!!
Voss
Voss 2022년 6월 13일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by