Attempt to execute SCRIPT varargin as a function:

if ndims(img) ~= 3
error('first argument should be a 3D image');
end
% in case of a label image, return a vector with a set of results
if ~islogical(img)
labels = unique(img);
labels(labels==0) = [];
epcd = zeros(length(labels), 1);
for i = 1:length(labels)
epcd(i) = imEuler3dDensity(img==labels(i), varargin{:});
end
return;
end
% Process user input arguments
delta = [1 1 1];
conn = 6;
while ~isempty(varargin)
var = varargin{1};
if ~isnumeric(var)
error('option should be numeric');
end
% option is either connectivity or resolution
if isscalar(var)
conn = var;
else
delta = var;
end
varargin(1) = [];
end
% Euler-Poincare Characteristic of each component in image
chi = imEuler3dEstimate(img, conn);
In this coding, following error
Attempt to execute SCRIPT varargin as a function:
C:\Program Files\mATLAB\R2019a\toolbox\matlab\lang\varargin.m

 채택된 답변

Matt J
Matt J 2022년 8월 14일

0 개 추천

Your function does not begin with the function declaration line.

댓글 수: 3

... and varargin can only be used inside a function.
The related nargin() and nargout() are primarily intended to be used inside a function, but they also have other uses when a function handle is passed into them.
Thanks
You're welcome but please Accept-click the answer to indicate that your question was resolved.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2022년 8월 14일

댓글:

2022년 8월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by