フィルターのクリア

how to use nanmean fxn with double precision elements?

1 回表示 (過去 30 日間)
Nahir
Nahir 2013 年 5 月 23 日
Hi, I have several variables from which I would like to calculate their mean:
ax1 ax2 ax3 ax4 ax5 are all 877x1 variables, each has many NaNs
Ax=[ax1 ax2 ax3 ax4 ax5]; %put all variables into a matrix Ax
Ax_avg=nanmean(Ax,2); %according to a search of the documentation mean(A,dim) and nanmean(A,dim) should return the mean values for elements along the dimension specified.
However, when I run the above code I get the following error: Undefined function 'nanmean' for input arguments of type 'double'.
I assume this is saying that each element in Ax is double precision...if so, I still don't see why the mean cannot be calculated this way.
This is probably a very easy fix with someone with the 'know how', but I've been at a loss; some guidance would be greatly appreciated. Thanks.
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2013 年 5 月 23 日
編集済み: Andrei Bobrov 2013 年 5 月 23 日
You have Statistics Toolbox?

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 5 月 23 日
編集済み: Andrei Bobrov 2013 年 5 月 23 日
t = isnan(Ax);
A1 = Ax;
A1(t) = 0;
Ax_avg = sum(A1,2)./sum(~t,2);
  1 件のコメント
Nahir
Nahir 2013 年 6 月 5 日
Thank you for the help...sorry for the delay in accepting (slipped me). I did look into it and it seems that I do have the statistics tool bar so not sure why the "nanmean" function did not work. Anyway, thanks again.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by