Not enough input arguments

1 次查看(过去 30 天)
Jefri Nainggolan
Jefri Nainggolan 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