필터 지우기
필터 지우기

Estimate length with out NaN's

조회 수: 86 (최근 30일)
George
George 2015년 3월 11일
댓글: Star Strider 2015년 3월 11일
Hello
I use the length command to see the length of some of my variables, although they include NaN's inside by a previous script I used so as to fill them and compare them Is there a way to find the length of the data non-taking into account the NaN?
I tried nanlength , as you can use nanmean etc. although it does not like it
it gives me this error
Undefined function 'nanlength' for input arguments of type 'double'.
  댓글 수: 1
Stephen23
Stephen23 2015년 3월 11일
편집: Stephen23 2015년 3월 11일
Keep in mind that length does not give the number of elements in an array: for this you should use numel .

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2015년 3월 11일
This works:
nonan_len = length(x(~isnan(x)));
  댓글 수: 2
George
George 2015년 3월 11일
Thank you very much, just what I needed !
Star Strider
Star Strider 2015년 3월 11일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015년 3월 11일
If x is your vector.
YourLength = length(x) - sum(isnan(x))

카테고리

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