フィルターのクリア

how to solve not enough input argument error?

3 ビュー (過去 30 日間)
Walaa
Walaa 2022 年 12 月 18 日
回答済み: Stephen23 2022 年 12 月 18 日
I am getting this error while trying to run the code below
Error using /
Not enough input arguments.
Error in filex(line 241)
col = (s.MajorAxisLength/2)*cos(theta);
% Calculate centroid, orientation and major/minor axis length of the ellipse
s = regionprops(binaryImage,{'Centroid','Orientation','MajorAxisLength','MinorAxisLength'});
% Calculate the ellipse line
theta = linspace(0,2*pi);
col = (s.MajorAxisLength/2)*cos(theta);
row = (s.MinorAxisLength/2)*sin(theta);
M = makehgtform('translate',[s.Centroid, 0],'zrotate',deg2rad(-1*s.Orientation));
D = M*[col;row;zeros(1,numel(row));ones(1,numel(row))];
  1 件のコメント
KSSV
KSSV 2022 年 12 月 18 日
What you are showing is a prt of code. Show us the full code with full error. The error is becuase to a function sufficient number of inputs are not passed.

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

採用された回答

Stephen23
Stephen23 2022 年 12 月 18 日
Your code is not written to handle cases when s is non-scalar. Your code assumes that s is scalar, but does not check this an any way.
The error is very simple to reproduce, because s is empty (i.e. REGIONPROPS did not detect anything):
s = struct('MajorAxisLength',{})
s = 0×0 empty struct array with fields: MajorAxisLength
theta = linspace(0,2*pi);
col = (s.MajorAxisLength/2)*cos(theta)
Error using /
Not enough input arguments.
You need to decide what your code should do when s is non-scalar: throw an error or do some alternate processing.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by