How to combine repeated same value to a single value or variable

X=[3 5 ; 1 2 ; 5 6 ; 3 5 ] How to make like Y=[3 5; 1 2; 5 6] ie; representing [3 5] for single time rather displaying it twice

답변 (1개)

Rik
Rik 2018년 3월 12일

1 개 추천

You can use unique.

댓글 수: 3

But this command holds good for matrix values, how to do for array values
See the 'rows' option.
That is why the link leads you to the 'rows' flag example:
[C,ia,ic] = unique(A(:,1:2),'rows')
In your case:
X=[3 5 ; 1 2 ; 5 6 ; 3 5 ];
Y=unique(X,'rows','stable');

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2018년 3월 12일

댓글:

Rik
2018년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by