Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: least-squares fitting: Setting up the objective function
Replies: 3   Last Post: Jan 31, 2014 9:50 AM

 Messages: [ Previous | Next ]
 GS Posts: 22 Registered: 4/19/12
least-squares fitting: Setting up the objective function
Posted: Jan 31, 2014 8:04 AM

I am working on a least-squares 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*k-exp(k*x(1))-exp(k*x(2));

Step 2: Call the nonlinear least-squares 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/nonlinear-least-squares-with-full-jacobian.html

Thanks.

Date Subject Author
1/31/14 GS
1/31/14 Torsten
1/31/14 GS
1/31/14 Torsten