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

3 vues (au cours des 30 derniers jours)
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.)

Réponse acceptée

Star Strider
Star Strider le 28 Jan 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 commentaires
Sakina
Sakina le 29 Jan 2018
Adding the function handle changed the error message, leading me to another error in the PBE_FUNCTION, which was then easily resolved. Thanks!
Star Strider
Star Strider le 29 Jan 2018
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming Utilities 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!

Translated by