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: Difference of cost functions in optimization?
Replies: 2   Last Post: Feb 22, 2013 6:32 AM

 Messages: [ Previous | Next ]
 Pascal Schulthess Posts: 5 Registered: 12/8/11
Difference of cost functions in optimization?
Posted: Feb 21, 2013 6:16 AM

Hi everyone,

I'm working quite a long time with lsqnonlin and comparable functions but now I'm wondering if there's a difference between the following two expressions of the cost function:

First:
f = [0,1];
function error = objFcn(p, x, y)
fit = zeros(size(ydata));
for i = 1:size(ydata, 1)
fit(i,:)= p(1)*x + f(i)*p(2);
end
error = fit-y;
end

And, secondly:
function error = objFcn(p, x, y)
fit = zeros(size(ydata));
fit(1,:)= p(1)*x;
fit(2,:)= p(1)*x + p(2);
error = fit-y;
end

I would really appreciate any help and possible explanations.

Thanks a lot,

Pascal

Date Subject Author
2/21/13 Pascal Schulthess
2/21/13 Alan Weiss
2/22/13 Pascal Schulthess