How to delete nan from array

B=[nan 8 nan;6 nan nan;6 5 8] C=[nan 4 nan;4 nan nan;5 3 2]
Answer: B=[8 6 6 5 8] C=[4 4 5 3 2]

 採用された回答

Guillaume
Guillaume 2015 年 1 月 13 日
編集済み: Guillaume 2015 年 1 月 13 日

5 投票

B = B';
B = B(~isnan(B))';
C = C';
C = C(~isnan(C))';

3 件のコメント

Adam
Adam 2015 年 1 月 13 日
You need a reassignment to B and C too in there:
B = B(~isnan(B))';
C = C(~isnan(C))';
Guillaume
Guillaume 2015 年 1 月 13 日
Yes, not sure what I was thinking.
Yang Liu
Yang Liu 2022 年 8 月 4 日
Why use '? Why not just B=B(~isnan(B))?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

タグ

質問済み:

2015 年 1 月 13 日

コメント済み:

2022 年 8 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by