Error in appliying split apply
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a problem using splitapply for function mean.
Error using splitapply (line 111)
For N groups, every integer between 1 and N must occur at least once in the vector of group numbers.
Error in try_31032019 (line 65)
LPInew = splitapply(@mean,LPI,bins_index);
G1 = findgroups(amax2);
bins_index = discretize(G1,amaxgrid);
LPInew = splitapply(@mean,LPI,bins_index);
CSR_new = splitapply(@mean,CSR,bins_index);
constN1_60_new = splitapply(@mean,N1_60,bins_index);
constFC_new = splitapply(@mean,Const,bins_index);
Is there any one can help me to solve my problem?
댓글 수: 7
Akira Agata
2019년 6월 26일
What you intended to do in your code is not clear for me. For example, I'm not sure how to fix the following 3 lines:
amaxgrid = linspace(0.19,0.42,36);
G1 = findgroups(amax);
bins_index = discretize(G1,amaxgrid);
Looking at your data file G1 should be integer 1~7, since amax consists of 7 different values. On the otherhand, amaxgrid becomes 1-by-36 double array between 0.19~0.42.
So I have no idea what you intended to do in the 3rd line. Could you tell us more details on what kind of calculation shall be done on your data?
채택된 답변
Mil Shastri
2019년 10월 12일
The group numbers provided to splitapply need to be every integer between 1 to N. For example:
This will work:
splitapply(@mean,1:5,[2,2,3,1,1])
and this will not because the group number 3 is missing:
splitapply(@mean,1:5,[2,2,4,1,1])
댓글 수: 2
Christoper Angelo Malayan
2021년 1월 10일
Is there a way for splitapply to SKIP this missing number and proceed to the next?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Preprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!