→ LiamIssac: idx = find(x(1,:) == a); 09/18 13:06
→ LiamIssac: y = mean(x(2, idx)) 09/18 13:07
推 sppmg: 假設重複只有一個且未知: 09/18 13:19
→ sppmg: [cc,ii]=sort(x(1,:)) 09/18 13:19
→ sppmg: idx=find(! diff([cc(1),cc])) 09/18 13:20
→ sppmg: idx=ii(find(! diff([cc(1),cc]))) % 上面請改這個比較好 09/18 13:22
→ sppmg: x(2,idx) = mean( x(2,idx) ) 09/18 13:23
感謝 如果假設不只一個 因為是一筆2萬行矩陣
第一行差不多有五六百多個會重複 請問怎麼改會比較好
※ 編輯: ismyname (101.14.49.216), 09/18/2017 13:45:54
推 sunev: 用內建的accumarray或histcounts都可以 09/18 14:18
推 sunev: A=accumarray(x(1,:)',x(2,:)',[],@mean);AA=find(A); 09/18 14:23
→ sunev: [AA A(AA)]' 09/18 14:23
推 sunev: histcounts好像不太行,那用accumarray就好了 09/18 14:31
感謝 accumarray可以執行
※ 編輯: ismyname (101.15.241.126), 09/20/2017 13:48:39