Problem with ''if''

Hi everyone, I have this variable:
values =
[] [1x27 char] [1x32 char] [1x28 char] [1x34 char]
and i want have a check for empty cells. I use :
if values[ ]==[ ]
....
end
But unfortunately....
??? Conversion to logical from cell is not possible. What can i do???

 Respuesta aceptada

Robert Cumming
Robert Cumming el 20 de Jul. de 2011

0 votos

cellfun ( @isempty, values )

5 comentarios

Jan
Jan el 20 de Jul. de 2011
CELLFUN('isempty') is remarkably faster than CELLFUN(@isempty).
alexis
alexis el 20 de Jul. de 2011
thank you for the answer but... I want my programme to stop when i have an non empty cell. I wan't to check the "values" and if the "values"is empty then i 'll continue my programme. Can you help me??
Robert Cumming
Robert Cumming el 20 de Jul. de 2011
presumably you have a for loop then so that you can stop/break? i.e.
for ii=1:length(values)
if isempty ( values{ii} )
break
end
end
Oleg Komarov
Oleg Komarov el 20 de Jul. de 2011
idx = cellfun('isempty',values);
find(~idx,1,'first')
Finds the location of the first non-empty.
alexis
alexis el 21 de Jul. de 2011
Thank you!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by