Removing NaN from cell array

111 ビュー (過去 30 日間)
Thulasi Durai Durai Samy
Thulasi Durai Durai Samy 2012 年 6 月 28 日
I have cell array which ends with NaN as last row
'Mat Name' 'MAT Type' 'E1'
'GFRP' 'GFRP' 'GFRP'
'CFRP' 'CFRP' 'CFRP'
'KFRP' 'KFRP' 'KFRP'
'SCDB' 'SCDB' 'SCDB'
'ABCD' 'ABCD' 'ABCD'
[NaN] [NaN] [ NaN]
How to remove the NaN from the last row of cell array
thanks in advance

採用された回答

Honglei Chen
Honglei Chen 2012 年 6 月 28 日
編集済み: Honglei Chen 2012 年 6 月 28 日
x = {'xy','yz',nan}
x(cellfun(@(x) any(isnan(x)),x)) = []
  8 件のコメント
Honglei Chen
Honglei Chen 2012 年 6 月 28 日
cellfun will loop each cell for you to check whether a cell is nan or not, but it does not preserve the dimension. So you need to reshape it back at the end.
Jan
Jan 2012 年 6 月 28 日
Another approach, which remove all non-strings: x = x(cellfun('isclass', x, 'char'))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Operations and Transformations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by