Unique value for each sequence of two corresponding variables
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I want to find the unique values for a sequence in A and the value corresponding value in B. For example:
A = [ 1 1 1 2 2 1 1 1 3 3 2 2 2 3 3 3]
B = [ 7 7 7 9 9 7 7 7 7 7 9 9 9 7 7 7]
output
Aa= [1 2 3]
Bb = [7 9 7]
How can I achieve this?
댓글 수: 0
채택된 답변
Jan
2021년 9월 26일
A = [ 1 1 1 2 2 1 1 1 3 3 2 2 2 3 3 3];
B = [ 7 7 7 9 9 7 7 7 7 7 9 9 9 7 7 7];
[Aa, iA] = unique(A, 'first');
Bb = B(iA);
Aa
Bb
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!