Effacer les filtres
Effacer les filtres

erasing all the rows that begin with NaN

1 vue (au cours des 30 derniers jours)
Sabbas
Sabbas le 9 Juil 2012
I have a cell matric.
The first two columns of this matrix are
[1x28 char] [ NaN]
[ NaN] [ NaN]
'MART' 'TOTATRIA'
'PREGORY' 'TOSTE'
[ NaN] [ NaN]
My goal is to erase these rows which have as a first element NaN
In the above example I want to erase row2 and the last one
thanks

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 9 Juil 2012
just
out = A(~cellfun(@(x)all(isnan(x)),A(:,1)),:)
  1 commentaire
Sabbas
Sabbas le 9 Juil 2012
it works!thnx

Connectez-vous pour commenter.

Plus de réponses (2)

Thomas
Thomas le 9 Juil 2012
If A is your input cell matrix
out=cellfun(@isnan,A(:,1),'UniformOutput',false)
count=cellfun(@(x)any(x==1),out);
A(~count,:)
  10 commentaires
Sabbas
Sabbas le 9 Juil 2012
Modifié(e) : Sabbas le 9 Juil 2012
it works for me when I choose the first two columns. But not when I use the whole matrix
Sabbas
Sabbas le 9 Juil 2012
Modifié(e) : Sabbas le 9 Juil 2012
I used
count=cellfun(@(x)any(x==1),out);
A(count==1,:)=[]
and it seems to work
could you plese verify that the code is equivalent to the one you provided?
thanks

Connectez-vous pour commenter.


Jan
Jan le 9 Juil 2012
Modifié(e) : Jan le 9 Juil 2012
A(cellfun(@(x) isequalwithequalnans(x, NaN), C), :)

Catégories

En savoir plus sur Data Type Identification dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by