필터 지우기
필터 지우기

check if the cells inside a cell array are empty by using if condition

조회 수: 123 (최근 30일)
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz 2019년 6월 10일
댓글: Walter Roberson 2019년 6월 10일
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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 6월 10일
if isempty(Pred_bbox{i})
  댓글 수: 2
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz 2019년 6월 10일
Thanks for your reply. I also have another issue. I have no numbers for some of the boxes inside Pred_bbox.mat file. When running the code I get below error:How can I solve this issue because I have no numbers for the box but it says that it should be size m*4.
Error using bboxOverlapRatio
The value of 'bboxB' is invalid. Expected input to be of size Mx4 when it is actually size 0x0.
Error in bboxOverlapRatio>validateAndParseInputs (line 125)
parser.parse(varargin{:});
Error in bboxOverlapRatio (line 61)
[bboxA, bboxB, ratioType] = validateAndParseInputs(varargin{:});
Error in IOUDPM2 (line 13)
overlapRatio{i} = bboxOverlapRatio(GT_bbox{i},Pred_bbox{i});
Walter Roberson
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 CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by