Find the standard error of the mean for each column in a matrix containing NaN and numerical values

10 ビュー (過去 30 日間)
I have a 5x4 matrix with NaN and numerical elements as shown below:
A = [ NaN NaN NaN 3.8905
NaN NaN NaN 3.4095
NaN NaN 3.0360 NaN
NaN NaN 2.5295 NaN ];
I was able to find the mean using nanmean and standard deviation using nanstd for each row but how do I calculate the standard error of the mean for each column in this matrix?
When I use length(A(~isnan(A))), size(A(~isnan(A)),1) and numel(A(~isnan(A))) for the non NaN values in this matrix, I always get the total number of non NaN values as opposed to non NaN values in each column.

採用された回答

Chris
Chris 2021 年 11 月 4 日
編集済み: Chris 2021 年 11 月 4 日
  1. That's a 4x4 matrix, not 5x4.
  2. The default behavior or nanmean and nanstd is to give you the statistic for each column. Taking the standard deviation of each row in this example would give you zeros.
  3. To get the number of non-nans in each column:
sum(~isnan(A))
standard error:
nanstd(A)./sqrt(sum(~isnan(A)))
  3 件のコメント
Leeba Chacko
Leeba Chacko 2021 年 11 月 4 日
Thanks Chris, this is really helpful!

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

その他の回答 (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