Error using + Matrix dimensions must agree.

function allCenters = getDominoValues(BW, bbox, colorIm)
for i = 1:length(bbox)
dominoImage = imcrop(BW, bbox(i,:));
[centers, radii] = imfindcircles(dominoImage, [3 8]);
dominoImageOffset = repmat(double(bbox(i,1:2)), (length(centers)/2), 1);
absoluteCenters{i} = centers(:,:) + dominoImageOffset(:,:);
allRadii{i} = radii;
end
J = colorIm;
for i = 1:length(bbox)
J = insertMarker(J, absoluteCenters{i});
end
imshow(J);
At the moment I am getting the following message "Error using + Matrix dimenions must agree" when "absoluteCenters{i} = centers(:,:) + dominoImageOffset(:,:);" is executed. I have executed the same line in the command script, and I get no error messages.
Does anyone know why this might be happening?
Thanks.

1 件のコメント

KSSV
KSSV 2016 年 10 月 19 日
You sure the dimensions of centers and dominoImageOffset are same? You can call them by centers + dominoImageOffset. centers(:,:) + dominoImageOffset(:,:) this is not required.

サインインしてコメントする。

 採用された回答

Jan
Jan 2016 年 10 月 19 日

0 投票

It is hard to guess remotely, but you can inspect the problem very easy locally:
dbstop if error
Then run your code again until it stops at the error. Now check the dimensions:
size(centers)
size(dominoImageOffset)
As Matlab tells you, they have different sizes.
Perhaps you do not mean length(centers), which is the longest dimension, but size(centers, 1). Never rely on length to pick up the dimension you are meaning.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePerformance and Memory についてさらに検索

タグ

質問済み:

2016 年 10 月 19 日

回答済み:

Jan
2016 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by