new array using average row of the old array
古いコメントを表示
I have an array M(1000,1000) and i want to build a new array N(1000,1000), where each element of N has the old value minus the average of its row (in M). If the element is zero no action will be taken. Also, from the average the zeros should be excluded.
Can you help me?
thank you in advance
採用された回答
その他の回答 (1 件)
Andrei Bobrov
2013 年 10 月 13 日
ii = M == 0;
out = bsxfun(@minus,M,sum(M,2)./sum(~ii,2));
out(ii) = 0;
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!