Delete Rows With empty elements

2 vues (au cours des 30 derniers jours)
T
T le 19 Août 2013
Suppose I have a set of data (a 2x9 matrix):
data2 =
[ 1] [0.0095] [5670000] [936] 'Normal' [0] [0] [0] [ NaN]
[ 2] [0.0095] [5670000] [936] 'Normal' [0] [0] [0] [ NaN]
[ 3] [0.0095] [5670000] [936] 'Normal' [0] [0] [0] [ NaN]
[ 4] [0.0095] [5670000] [936] 'Normal' [0] [0] [0] 'some text'
[ 5] [0.0095] [5670000] [936] 'Normal' [0] [0] [0] 'some text'
I want to be able to detect the NaN's and delete the first three columns.
Typically this is done through
data1(find(sum(isnan(data2),2)==0),:)
but isnan is for input arguements of type 'cell'. What else can I try?
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 19 Août 2013
Do you want to delete just 3 rows?
T
T le 19 Août 2013
Yes.

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 19 Août 2013
data1(any(cellfun(@(x) any(isnan(x)),data1),2),:)=[]
  3 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 19 Août 2013
Modifié(e) : Azzi Abdelmalek le 19 Août 2013
Why have you changed data1? this has nothing to do with your question
T
T le 19 Août 2013
Sorry, the original post should have read data2.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays 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