not enough input arguments - fsolve and function handles
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Torsten
le 3 Juin 2016
coeff = fsolve(@(x)ts_7(x(1),x(2),x(3),x(4),x(5)), init, opts);
Best wishes
Torsten.
5 commentaires
Walter Roberson
le 5 Juin 2016
Please post your complete current code including the creation of opts.
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!