Not enough input arguments
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 6 Apr 2020
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.
0 Comments
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!