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 Center および File ExchangeNumbers and Precision についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by