Not enough input arguments

조회 수: 1 (최근 30일)
Jefri Nainggolan
Jefri Nainggolan 2020년 4월 6일
답변: Walter Roberson 2020년 4월 6일
can anyone help me with this error?
Error in diva (line 25) Not enough input arguments.
function divF=diva(F,coords)
%find the analytical divergence of a given symbolic 3D vector function F
% coords = 'car'/'cyl'/'sph'
% Copyleft: Won Y. Yang, wyyang53@hanmail.net, CAU for academic use only
if nargin<2, coords='ca'; end
% Cartesian coordinate system by default switch lower(coords(1:2))
% Depending on which coordinate system to use
% Depending on which coordinate system to use
switch lower(coords(1:2))
case 'cy'
syms r ph z;
coord = 'cylindrical';
divF = diff(r*F(1),r)/r + ...
diff(F(2),ph)/r + ...
diff(F(3),z); %(2.4.4b)
case 'sp'
syms r th ph; coord='spherical';
divF = diff(r^2*F(1),r)/r^2 + ...
diff(F(2)*sin(th),th)/r/sin(th) + ...
diff(F(3),ph)/r/sin(th); %(2.4.4c)
otherwise % coords ='ca'
syms x y z;
coord='Cartesian';
divF = diff(F(1),x) + ...
diff(F(2),y) + ...
diff(F(3),z); %(2.4.4a)
end
if nargout<1
fprintf(['Div(F) in ' coord ' coordinate is']);
pretty(simplify(DivF))
end

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 6일
You would get that error if you are passing in a function handle as the first parameter, and the function handle requires more than one parameter.
The code expects that the first parameter is either an array of 3 symbolic expressions, or else that it is a numeric array, or else it is a function handle with one parameter.

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by