Set an empty cell array equal to zero.

18 vues (au cours des 30 derniers jours)
JE
JE le 15 Oct 2015
Modifié(e) : Image Analyst le 16 Oct 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.

Réponse acceptée

dpb
dpb le 15 Oct 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).
  1 commentaire
JE
JE le 15 Oct 2015

I LOVE YOU.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and 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