フィルターのクリア

A simple question

1 回表示 (過去 30 日間)
Alessandro Innocenti
Alessandro Innocenti 2012 年 6 月 21 日
Hi! I have multiple NaNs in my 60x3 matrix. I want to average out the first three values for each column, without considering NaN.
For example:
1 2 3
Nan 5 6
7 8 Nan
10 11 12
13 Nan 15
16 17 18
Mean:
4 (1+7/2) 5 (8+2+5/3) 4.5 (6+3/2)
13(10+13+16/3) 14(11+17/2) 15 (12+15+18)
I think it isn't difficult but I'm not very able with Matlab.. Thank you. Ale

採用された回答

Richard
Richard 2012 年 6 月 21 日
If you have 60 rows and 3 columns in matrix 'a' then you can find the mean of each row i.e. the first three values as you stated above then you should use:
nanmean(a,2);
nanmean calculates the mean without considering the nan and the 2, tells matlab to calculate the mean along the second dimension i.e. for each row. stating nanmean(a,1) would calculate the mean for each individual column thus returning 60 values. Hope this helps

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by