isnan cellfun and dropping rows
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
phlie
el 13 de Sept. de 2016
Comentada: Stephen23
el 13 de Sept. de 2016
Hi, in my cell array X, I would like to drop all rows where the value of the 4th column is NaN (the new cell array is Y).
I am trying this:
Y = X(~any(cellfun(@isnan,X(:,4),'UniformOutput',false),2),:)
It returns the following error: Undefined function 'any' for input arguments of type 'cell'.
How do I have to change the code?
1 comentario
Stephen23
el 13 de Sept. de 2016
Not enough information: what is the cell array? What size are the arrays inside the cell array? Are all cell contents numeric?
Respuesta aceptada
Stephen23
el 13 de Sept. de 2016
Editada: Stephen23
el 13 de Sept. de 2016
Making some guesses here, but this might do what you want:
Y = X(cellfun(@(x)any(isnan(x)),X(:,4)),:)
2 comentarios
Stephen23
el 13 de Sept. de 2016
If the content of each cell is a scalar, you could even do this:
Y = X(~cellfun(@isnan,X(:,4)),:)
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!