B=nanstd(X,0,'all');
when using the above statement in Matlab R2019a there are no problems, however when using it on another computer with R2017a, i get the error:
Error using size
Dimension argument must be a positive integer scalar within indexing range.
Error in var (line 109)
n = size(x,dim);
Error in nanvar (line 32)
y = var(varargin{:},'omitnan');
Error in nanstd (line 28)
y = sqrt(nanvar(varargin{:}));

 採用された回答

Adam Danz
Adam Danz 2019 年 12 月 17 日
編集済み: Adam Danz 2019 年 12 月 17 日

0 投票

If you're computing the std over all elements of X, this works in any release.
B = std(X(~isnan(X)));

1 件のコメント

Adam Evenoff
Adam Evenoff 2019 年 12 月 17 日
That works, thanks!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 12 月 17 日

0 投票

The ability to specify 'all' as a dimension in the var function (which the nanstd function calls) was introduced in release R2018b.

2 件のコメント

Adam Evenoff
Adam Evenoff 2019 年 12 月 17 日
Is there any other tool/way on R2017a to calculate standard deviation while omitting NaN values?
Steven Lord
Steven Lord 2019 年 12 月 17 日
The 'omitnan' option was introduced in release R2015a.
M = magic(5);
M(3, 3) = NaN;
std(M(:), 'omitnan')

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

カテゴリ

ヘルプ センター および File ExchangeContour Plots についてさらに検索

タグ

質問済み:

2019 年 12 月 17 日

コメント済み:

2019 年 12 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by