필터 지우기
필터 지우기

Reverse of find groups

조회 수: 7 (최근 30일)
Haneya Qureshi
Haneya Qureshi 2021년 12월 17일
편집: Jan 2021년 12월 17일
I have used findgroups to convert 2 column data to single column unique values. Like 1,1 was converted to 1. 1,2 to 2. 2,1 to 3. 2,2 to 4 and so on. I now want to reverse this operation, i.e., given integer from 1 to 48, I would like to get back the two column values.

답변 (1개)

Jan
Jan 2021년 12월 17일
편집: Jan 2021년 12월 17일
Use the 2nd output of findgroups:
A = [1,1; 1,2; 2,2; 3,3; 3,4; 1,3; 1,2];
[G, ID1, ID2] = findgroups(A(:, 1), A(:, 2));
AG = [ID1, ID2];
Now the i.th row of AG contains the 2 column values of the i.th group of G.
AG(3, :)
ans = 1×2
1 3
I assume unique('rows') is more efficient here.

카테고리

Help CenterFile Exchange에서 Power Converters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by