필터 지우기
필터 지우기

number of special array in a table

조회 수: 1 (최근 30일)
Abo
Abo 2019년 2월 5일
댓글: Guillaume 2019년 2월 5일
Hi,
I have a table (100*1) contains different number of "2" (see the following image) and "NAN" which changing dynamically. the question is how can I count number of "2" before each "NAN"?
regrds

채택된 답변

Guillaume
Guillaume 2019년 2월 5일
편집: Guillaume 2019년 2월 5일
It doesn't look like you have a table. It looks like a plain vector.
Anyway,
lengthofruns = diff([1; find(isnan(yourvector)); numel(yourvector)])
Basically, find the position of all the nans, then take the difference between consecutive positions to know the lengths of the runs.
  댓글 수: 2
madhan ravi
madhan ravi 2019년 2월 5일
+1 , one closing paranthesis ")" is missing before numel()
Guillaume
Guillaume 2019년 2월 5일
Thanks, fixed.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by