Delete rows with NaN for a cell array

17 ビュー (過去 30 日間)
Rooy
Rooy 2013 年 6 月 26 日
コメント済み: YING CONG XIAO 2021 年 4 月 21 日
I want to remove the rows that have NaN and still keep the dimension of the array intact.
[ NaN] [ NaN] [ NaN] [ NaN]
[ NaN] [ NaN] [ NaN] [ NaN]
'Total RADIO Drops' 'Total Drops' 'CC DCR (%)' 'RADIO DCR (%)'
Above is just an example, I have over a thousand rows.
The only problem I have now is removing rows which have NaN and string together
Thank you
  1 件のコメント
Rooy
Rooy 2013 年 6 月 26 日
Is there a way to delete the rows which have strings and Nan mixed together ?
[ 'A'] [ NaN] [ NaN] [ NaN]
'Total RADIO Drops' 'Total Drops' 'CC DCR (%)' 'RADIO DCR (%)'

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

採用された回答

Tom
Tom 2013 年 6 月 26 日
A(any(cellfun(@(x) any(isnan(x)),A),2),:) = [];
  1 件のコメント
Rooy
Rooy 2013 年 6 月 26 日
Thank you, it works

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 6 月 26 日
編集済み: Andrei Bobrov 2013 年 6 月 26 日
A - your cell array
out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:);
ADD
out = A(all(cellfun(@(x)any(~isnan(x)),A),2),:);
  4 件のコメント
Rooy
Rooy 2013 年 6 月 26 日
Thank you for your great help
YING CONG XIAO
YING CONG XIAO 2021 年 4 月 21 日
hi Andrei,
how to specify the range in this fun:
out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:);

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by