check if the cells inside a cell array are empty by using if condition
조회 수: 124 (최근 30일)
이전 댓글 표시
I have a cell array with size (1*100). Some of the cells inside this cell array are empty and have no numbers and have [ ].By clicking on those cells empty page is shown.
My aim is to write a code with if condition to check if the cells inside this cell array are empty then put zero for overlapRatio in below code.
My code:
load('preds_gt_DPM2.mat'); %cell array with size 1*100 %preds_gt_DPM2.mat contains two cell arrays. Pred_bbox and GT_bbox
load('Pred_bbox.mat');
overlapRatio = {};
for i = 1 : size(GT_bbox,2)
overlapRatio{i} = bboxOverlapRatio(GT_bbox{i},Pred_bbox{i});
if Pred_bbox{i}=[]
overlapRatio{i}=0
end
end
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 6월 10일
if isempty(Pred_bbox{i})
댓글 수: 2
Walter Roberson
2019년 6월 10일
nGT = size(GT_bbox,2);
overlapRatio = zeros(1, nGT);
for i = 1 : nGT
if isempty(Pred_bbox{i})
overlapRatio(i) = 0;
else
overlapRatio(i) = bboxOverlapRatio(GT_bbox{i},Pred_bbox{i});
end
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!