find the same values and average it out
1 回表示 (過去 30 日間)
古いコメントを表示
I have the following matrix A:
A =
66 2
66 3
66 4
67 6
67 3
68 5
69 6
69 3
what I would like to do is find the values that are the same in the first column and average the values in the second column and put it into a new matrix (B).
for example: I look for "66" and average the corresponding values in the second columns (i.e. 2,3,4) and the the mean is 3. So the first entry in matrix B will be:
B =
66 3
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2014 年 8 月 19 日
A =[ 66 2
66 3
66 4
67 6
67 3
68 5
69 6
69 3]
[ii,jj,kk]=unique(A(:,1))
out=[ii accumarray(kk,A(:,2),[],@mean)]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!