Set an empty cell array equal to zero.

18 visualizaciones (últimos 30 días)
JE
JE el 15 de Oct. de 2015
Editada: Image Analyst el 16 de Oct. de 2015
So I have a cell array that equals {[]} because it's empty. How can I create an empty array equal to zero using an if then statement?
My attempt:
if strcmp(stopcodon1,'[]');
stopcodon1=0;
end
It doesn't work at all.

Respuesta aceptada

dpb
dpb el 15 de Oct. de 2015
Actually, the cell array itself is not empty, it holds an empty array. And, empty isn't a string value anyway so that comparison wouldn't work even if there were an equality test for empty (which there isn't). All in all, that's barking up the wrong tree entirely... :)
if isempty(stopcodon1{:})
...
should lead to nirvana. Or, of course, modify program logic to not create the cell variable if the array itself is empty (altho that may break some other symmetry in algorithms, granted).

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by