How to determine mean values for a table containing nanovalues (where mean values of parts of the rows should be considered individually)
1 回表示 (過去 30 日間)
古いコメントを表示
I have a table with a lot of rows and a few cols. I want to split the rows for one cols into 10parts in order to analyze the different mean value of each of the 10 parts separately. Unfortunately in some of the 10parts are NaN values. But the following code can't ignore the NaN values, although i am using the nanmean command and thus, for some parts the nanmean value is = NaN^. Anyone know the reason for this happening? Or can someone recommand me a different syntax/code?
Here's my code:
for i=1:10 % for loop to determine 10 mean values %462120 = data collected in 2mins
k(i)=nanmean(Tabk(Tabk>0+(i-1)*462120 & Tabk<i*462120));
s(i)=nanmean(Tabs(Tabs>0+(i-1)*462120 & Tabs<i*462120));
i=i+1;
end
% to calculate the difference
K = transpose(k); %Transponierter Vektor v
S = transpose(s);
D = K-S;
0 件のコメント
回答 (1 件)
Jyotish Kumar
2019 年 5 月 22 日
Hi,
I understand that you are trying to find mean ignoring NaN values. ‘nanmean’ is the right syntax for this purpose and returns mean value ignoring NaN. But it returns NaN if all the elements in the matrix are NaN.
For e.g. nanmean(A) returns 2 for A= [1, NaN, 3] but nanmean(A) returns NaN for A = [NaN, NaN, NaN].
Please refer to this documentation link for more details:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!