deleting all the empty rows

Dear all,
I have
[N,T,R]]=xlsread(name);
I want to erase all the empty rows in T.
I suggest
T( all(cellfun(@isempty,T),2), : ) = [];
Am i correct?

3 comentarios

per isakson
per isakson el 13 de Jul. de 2012
YES
antonet
antonet el 13 de Jul. de 2012
cheers per
Stephen23
Stephen23 el 25 de Sept. de 2014
Editada: Stephen23 el 25 de Sept. de 2014
A little speed-up that is sometimes worth keeping in mind:
T(all(cellfun('isempty',T),2),:) = [];
There are some special cases (which run faster), where the functions can be supplied as a string. See the cellfun docs for more info.

Iniciar sesión para comentar.

Respuestas (1)

Greg Heath
Greg Heath el 13 de Jul. de 2012

1 voto

I don't think MATLAB allows empty rows or columns
>> A = [ 1 2 3; [] [] [] ; 7 8 9 ]
A = 1 2 3
7 8 9
>> A = [ 1 [] 3; 4 [] 6; 7 [] 9 ]
A = 1 3
4 6
7 9
>> A = [ [] 2 3; 4 [] 6; 7 8 [] ]
A = 2 3
4 6
7 8
Hope this helps.
Greg

2 comentarios

Nirmal
Nirmal el 13 de Jul. de 2012
Editada: Nirmal el 13 de Jul. de 2012
T in this case is cell array not the matrix and the cell can have empty string.
Greg Heath
Greg Heath el 25 de Sept. de 2014
Correct:
>> A = { 1 2 3; [] [] [] ; 7 8 9 }, B = { 1 [] 3; 4 [] 6; 7 [] 9 }, C = { [] 2 3; 4 [] 6; 7 8 [] }
A = [1] [2] [3]
[] [] []
[7] [8] [9]
B = [1] [] [3]
[4] [] [6]
[7] [] [9]
C = [] [2] [3]
[4] [] [6]
[7] [8] []

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Jul. de 2012

Editada:

el 25 de Sept. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by