Filter löschen
Filter löschen

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

124 Ansichten (letzte 30 Tage)
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

Antworten (1)

Walter Roberson
Walter Roberson am 10 Jun. 2019
if isempty(Pred_bbox{i})
  2 Kommentare
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz am 10 Jun. 2019
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 am 10 Jun. 2019
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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by