What is the simplest way to extract lengths of NaN sequences from a vector?
古いコメントを表示
What is the simplest way to extract lengths of NaN sequences from a vector? Plus the indices of their locations!
採用された回答
その他の回答 (1 件)
Bruno Luong
2018 年 10 月 2 日
編集済み: Bruno Luong
2018 年 10 月 2 日
% a is the input vector
b = isnan(a);
counts = sum(b);
positions = find(b);
3 件のコメント
Stephen23
2018 年 10 月 2 日
+1 isnan is correct.
Mr M.
2018 年 10 月 2 日
Bruno Luong
2018 年 10 月 2 日
編集済み: Bruno Luong
2018 年 10 月 2 日
Sorry, for sequence:
b = isnan(a(:)');
d = diff([0 b 0]);
i1 = find(d==1);
i9 = find(d==-1)-1;
if ~isempty(lgt)
fprintf('nan from (%d,%d)\n', [i1;i9]);
end
カテゴリ
ヘルプ センター および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!