number of non nan observations

조회 수: 35 (최근 30일)
joseph Frank
joseph Frank 2011년 7월 31일
Hi,
I have a matrix for which i need for each row to compute the number of non nan observations . such routine is occurring frequently in my program. I am wondering if it is possible to compute it without any loop. for example
0.81 0.10 NaN
0.91 NaN 0.97
0.91 NaN 0.97
NaN 0.55 0.96
0.91 0.96 0.49
NaN NaN NaN
is it possible to get [2;2;2;2;3;0] without running a loop?

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 7월 31일
sum(~isnan(In),2)

추가 답변 (1개)

the cyclist
the cyclist 2011년 7월 31일
sum(not(isnan(x)),2)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by