fsolve problem-I must be missing something

I am trying to fit two vectors A and L using the function:
function F = onesite(x,A,L)
Amax=x(1)
Kd=x(2)
F=A-(Amax*Kd*(L-(A/Amax))/(1+Kd*(L-(A/Amax))))
end
to find the best fit scalars Amax and Kd by defining the start points for x:
x=[1:10]
then using fsolve to find the optimal values
f=fsolve(@onesite,x,A,L)
Despite defining A,L, and the start points for x, I get the error:
Error using onesite (line 4)
Not enough input arguments.
What am i missing here?
Thanks

 Respuesta aceptada

Star Strider
Star Strider el 23 de Abr. de 2015
One possible solution:
f=fsolve(@(x)onesite(x,A,L),X0);
where ‘X0’ is your vector of initial estimates for ‘x’.
It’s also a good idea to vectorise your functions (doing element-wise or array operations) unless you specifically want to do matrix operations:
F=A-(Amax.*Kd.*(L-(A./Amax))./(1+Kd.*(L-(A./Amax))));
Putting periods in front of certain operators converts them from matrix to array operators.

2 comentarios

John Hackett
John Hackett el 24 de Abr. de 2015
f=fsolve(@(x)onesite(x,A,L),X0);
Solves the problem. Thank you very much!
Star Strider
Star Strider el 24 de Abr. de 2015
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 23 de Abr. de 2015

Comentada:

el 24 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by