フィルターのクリア

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

124 ビュー (過去 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 Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by