not enough input arguments - fsolve and function handles
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I asked the similar question a few days back but I still couldn't solve the problem so now I changed the code but I keep getting an error that I have too many input arguments.
function eq = ts_7(A,B,C,D,E)
syms x
% dbstop if error
% primary coefficients
g = D * sin(C * atan( B*x - E * (B*x - atan(B*x)))) + A; % magic formula
eq5 = taylor(g, x, 'Order',1, 'ExpansionPoint',7) + 4296; % x^0
eq1 = taylor(g, x, 'Order',2, 'ExpansionPoint',7) - eq5 + 296.3; % x^1
eq2 = taylor(g, x, 'Order',3, 'ExpansionPoint',7) - eq1 - 79.77; % x^2
eq3 = taylor(g, x, 'Order',4, 'ExpansionPoint',7) - eq2 - 4.541; % x^3
eq4 = taylor(g, x, 'Order',5, 'ExpansionPoint',7) - eq3 - 0.03358; % x^4
x = 8;
eq{1} = matlabFunction(eq1) % syms to numeric function
eq{2} = matlabFunction(eq2)
eq{3} = matlabFunction(eq3)
eq{4} = matlabFunction(eq4)
eq{5} = matlabFunction(eq5)
end
and my main looks like this:
opts = optimoptions('fsolve','InitDamping',0.005,'Algorithm','levenberg-marquardt');
init = [-1.3, 1.4, 4000, 0.12, 9]; % starting points
tic
coeff = fsolve(@(init)ts_7(init), init, opts);
toc
Error:
Undefined function or variable "fuser".
Error in fsolve (line 257)
if ~isempty( isoptimargdbl('FSOLVE', {'F','J'}, fuser, JAC) )
Error in script_7 (line 11)
coeff = fsolve(@(x)ts_7(x(1), x(2), x(3), x(4), x(5)), init,opts);
Error in run (line 96)
evalin('caller', [script ';']);
0 件のコメント
回答 (1 件)
Torsten
2016 年 6 月 3 日
coeff = fsolve(@(x)ts_7(x(1),x(2),x(3),x(4),x(5)), init, opts);
Best wishes
Torsten.
5 件のコメント
Walter Roberson
2016 年 6 月 5 日
Please post your complete current code including the creation of opts.
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!