Delete rows with NaN for a cell array

12 vues (au cours des 30 derniers jours)
Rooy
Rooy le 26 Juin 2013
Commenté : YING CONG XIAO le 21 Avr 2021
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 commentaire
Rooy
Rooy le 26 Juin 2013
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 (%)'

Connectez-vous pour commenter.

Réponse acceptée

Tom
Tom le 26 Juin 2013
A(any(cellfun(@(x) any(isnan(x)),A),2),:) = [];
  1 commentaire
Rooy
Rooy le 26 Juin 2013
Thank you, it works

Connectez-vous pour commenter.

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 26 Juin 2013
Modifié(e) : Andrei Bobrov le 26 Juin 2013
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 commentaires
Rooy
Rooy le 26 Juin 2013
Thank you for your great help
YING CONG XIAO
YING CONG XIAO le 21 Avr 2021
hi Andrei,
how to specify the range in this fun:
out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by