# Using find command to group data into bins

조회 수: 2(최근 30일)
Ivan Mich 2021년 7월 26일
댓글: dpb 2021년 7월 26일
I have one ascii file with 2 columns (1st X and 2nd Y) .
I want to group the elements of X into bins (e.g. [2-4,4-6, etc) and I would like to group values of Y values based on the group of X values.
How could I use find command in order to make it?

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

### 답변(3개)

Cris LaPierre 2021년 7월 26일
I wouldn't try to use find. I would try to use discretize, findgroups, or histcounts (or maybe histcounts2) instead.
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

dpb 2021년 7월 26일
find is not the tool for this; see
grpstats or groupsummary or for more generality, findgroups combined with splitapply
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

Sulaymon Eshkabilov 2021년 7월 26일
If I have undersood your question correctly, in this case, find() is not quite efficient. Thus, you can better create just indxes, e.g.:
A1 = [X(2:4), Y(2:4)];
A2 = [X(4:6), Y(4:6)];
% OR:
XY=[X,Y];
B1 = XY(2:4,:);
B2 = XY(4:6,:);
##### 댓글 수: 1표시숨기기 없음
dpb 2021년 7월 26일
group the elements of X into bins (e.g. [2-4,4-6, etc)"
Raises the Q? of just precisely does this mean? I and Chris interpreted as grouping by the values of X whereas Sulaymon's A assumes just on the index order.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by