フィルターのクリア

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 Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by