Error in appliying split apply
古いコメントを表示
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 件のコメント
Walter Roberson
2019 年 6 月 9 日
bins_index = findgroups(discretize(G1,amaxgrid));
Skydriver
2019 年 6 月 25 日
Skydriver
2019 年 6 月 25 日
Walter Roberson
2019 年 6 月 25 日
You should not use @mean for this purpose: you should use @(x) mean(x,1) to force mean along the first dimension. Otherwise if you happen to get a group that has only a single row, then that would show up as mean(a_row_vector) which would be interpreted as mean of the vector, giving a scalar result, whereas mean() of a 2D would be mean per column giving a vector result.
Skydriver
2019 年 6 月 25 日
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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!