How to find standard deviation of all entries in a range and omit nan

8 ビュー (過去 30 日間)
Adam Friedman
Adam Friedman 2021 年 9 月 25 日
回答済み: Chunru 2021 年 9 月 26 日
Suppose I have a matrix that contains NaN entries. I want to find the the standard deviation of all entries in the range (r1:r2,c1:c2) and omit NaN entries. Is there a way to do this without extracting data range first and storing it as a new entry?
I Want to avoid this
A=rand(10);
ssA=A(2:4,3:7); % Sub Set of A
StdssA=std(ssA(:),'omitnan')
And instead do something like this:
A=rand(10);
StdssA=std(A(2:4,3:7),'omitnan')
Unfortunately, this only gives me the std of this range based on whatever dim I specifiy. I want to get the std of all elements in this range with one line of code.

回答 (1 件)

Chunru
Chunru 2021 年 9 月 26 日
A=rand(10);
StdssA=std(A(2:4,3:7), 0, 'all', 'omitnan') % doc std
StdssA = 0.3421

カテゴリ

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

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by