Effacer les filtres
Effacer les filtres

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

124 vues (au cours des 30 derniers jours)
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz le 10 Juin 2019
Commenté : Walter Roberson le 10 Juin 2019
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

Réponses (1)

Walter Roberson
Walter Roberson le 10 Juin 2019
if isempty(Pred_bbox{i})
  2 commentaires
Sahar Pordeli Behrouz
Sahar Pordeli Behrouz le 10 Juin 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 le 10 Juin 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by