how do i count NaNs in a vectors or array??

Sir I have a vector say
A=[5,5,6,NaN,NaN,8,10,5,7,3,NaN,11,5,3,8,9,7,NaN,NaN,NaN,NaN,NaN]
and i want to count the number of NaNs in between the numbers. The result should be[2,1,5]. how can I do it sir? please help

 採用された回答

Matt J
Matt J 2015 年 2 月 1 日
編集済み: Matt J 2015 年 2 月 1 日

0 投票

If you have the Image Processing Toolbox,
S=regionprops(isnan(A),'Area');
result=[S.Area];

その他の回答 (1 件)

Matt J
Matt J 2015 年 2 月 1 日

0 投票

Using SplitVec ( Download ),
C=SplitVec(isnan(A),'equal',@sum);
result=nonzeros([C{:}]).';

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2015 年 2 月 1 日

回答済み:

2015 年 2 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by