How to determine mean values for a table containing nanovalues (where mean values of parts of the rows should be considered individually)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jyotish Kumar
el 22 de Mayo de 2019
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 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!