필터 지우기
필터 지우기

Hi, I want to group my data into 11 groups

조회 수: 7 (최근 30일)
Alamgir M S M
Alamgir M S M 2019년 3월 9일
댓글: Alamgir M S M 2019년 3월 10일
This is my Data-
[705.7142857 705.7142857 173.4285714 84.71428571 232.5714286 232.5714286 114.2857143 55.14285714 25.57142857 74.85714286 35.42857143 15.71428571 5.857142857 5.857142857].
I want to group same data into 1 group. This is 14*1 matrix where it has 3 pairs(705.7142857 705.7142857, 232.5714286 232.5714286 & 5.857142857 5.857142857) of same value data. So, I want these 3 pairs into 3 groups and rest of them into other 8 groups.
Is there anybody who can help me to code this?

채택된 답변

Walter Roberson
Walter Roberson 2019년 3월 9일
Supposing your data is in vector v then
[~, ~, uidx] = unique(v);
grouped = accumarray(uidx, v, [], @(V) {V});
  댓글 수: 5
Alamgir M S M
Alamgir M S M 2019년 3월 10일
Hello Walter,
Do you know any method to keep the grouping in the same sequence as my original data?
Your code and mine both are working to make group but it's changing the sequence. it's following the ascending format.
Is there any method just to group only same values but not change the sequence?
Alamgir M S M
Alamgir M S M 2019년 3월 10일
This worked as I inteded:
y=[705.7142857
705.7142857
173.4285714
84.71428571
232.5714286
232.5714286
114.2857143
55.14285714
25.57142857
74.85714286
35.42857143
15.71428571
5.857142857
5.857142857];
group = findgroups(y);
uniqueGroups = unique(group,'stable');
Thanks :)

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by