Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
leastsquares fitting: Setting up the objective function
Replies:
3
Last Post:
Jan 31, 2014 9:50 AM



GS
Posts:
22
Registered:
4/19/12


leastsquares fitting: Setting up the objective function
Posted:
Jan 31, 2014 8:04 AM


I am working on a leastsquares fitting problem and I am looking at the lsqnonlin() example below. I have a similar problem. Except, the "k" here is the data I have. How do I setup the objective function if I have to pass this data to the objective function?
It is not apparent in this example where the summation is occurring
**************** Step 1: Write a file myfun.m that computes the objective function values. function F = myfun(x) k = 1:10; F = 2 + 2*kexp(k*x(1))exp(k*x(2));
Step 2: Call the nonlinear leastsquares routine. x0 = [0.3 0.4]; % Starting guess [x,resnorm,res,eflag,output1] = lsqnonlin(@myfun,x0); % Invoke optimizer ****************
Source: http://www.mathworks.com/help/optim/ug/nonlinearleastsquareswithfulljacobian.html
Thanks.



