필터 지우기
필터 지우기

Set an empty cell array equal to zero.

조회 수: 13 (최근 30일)
JE
JE 2015년 10월 15일
편집: Image Analyst 2015년 10월 16일
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.

채택된 답변

dpb
dpb 2015년 10월 15일
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).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by