Why is the lsqnonlin function telling me I don't have enough input arguments?

2 visualizaciones (últimos 30 días)
I have the following main:
K0=[60.2,1.4,14.7,2.3e12];
[K, resnorm]= lsqnonlin(myfun, K0)
Given myfun:
function [ F ] = myfun( K )
d32e=[580.8045;643.367;698.974;522.9306;645.1539;672.7778;679.3988;422.6795;594.0621;715.9881;469.7453;574.4126;626.5233;758.8268];
F=PBE_FUNCTION(K)-d32e;
end
in Matlab 2015b.
When I attempt to run the main, I get:
Not enough input arguments.
Error in myfun (line 4) F=PBE_FUNCTION(K)-d32e;
Error in Main (line 4) [K, resnorm]= lsqnonlin(myfun, K0)
How can I make it run?
(Please note that the PBE_FUNCTION uses other functions in its script, dependent on K.)

Respuesta aceptada

Star Strider
Star Strider el 28 de En. de 2018
One problem is that you need to use ‘@’ to create a function handle for ‘myfun’ in the lsqnonlin call:
[K, resnorm]= lsqnonlin(@myfun, K0)
I cannot run your code, so I do not know is the only problem.
  2 comentarios
Sakina
Sakina el 29 de En. de 2018
Adding the function handle changed the error message, leading me to another error in the PBE_FUNCTION, which was then easily resolved. Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming Utilities en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by