フィルターのクリア

subtract from each element its mean / find absolute deviation across rows

2 ビュー (過去 30 日間)
Ms. Mat
Ms. Mat 2013 年 1 月 17 日
A = [1 2 NaN; 4 NaN 6; 7 8 9]
A =
1 2 NaN
4 NaN 6
7 8 9
mn = nanmean(A,2)
mn =
1.5000
5.0000
8.0000
I would like to subtract each element by its corresponding row average as shown below(i.e find absolute deviations from mean),
1-1.5 2-1.5 NaN
4-5 NaN 6-5
7-8 8-8 9-8
Note the below array has no negative values as I am trying to find modulus of deviations.
0.5 0.5 NaN
1 NaN 1
1 0 1
Then sum up each row and divide by no. of elements.
(-0.5+0.5)/2
(-1 + 1)/2
(-1 + 0 + 1)/3
How can I achieve this result vector using arrayfun or by any other method ?
I am trying to find teh absolute deviation of each element in the array. i.e std.dev without the sq

採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 17 日
nanmean(abs(bsxfun(@minus A, nm)),2)
  1 件のコメント
Ms. Mat
Ms. Mat 2013 年 1 月 17 日
編集済み: Walter Roberson 2013 年 1 月 17 日
Thank You !!!
nanmean(abs(bsxfun(@minus, A, nm)),2)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by