MATLAB: Is the lsqnonlin function telling me I don’t have enough input arguments

2015binput argumentslsqnonlin

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.)

Best Answer

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.