Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Difference of cost functions in optimization?
Replies: 2   Last Post: Feb 22, 2013 6:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Pascal Schulthess

Posts: 5
Registered: 12/8/11
Re: Difference of cost functions in optimization?
Posted: Feb 22, 2013 6:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Alan_Weiss <aweiss@mathworks.com> wrote in message <kg5piv$7ss$1@newscl01ah.mathworks.com>...
> On 2/21/2013 6:16 AM, Pascal Schulthess wrote:
> > 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

>
> Well, I'm not sure what is the error or warning you are seeing, or what
> is the problem you are experiencing.
>
> If I have to guess, it seems to me that the "fit" matrix has a different
> size in the second formulation than in the first. But I really don't
> know, because you haven't told us the size of your matrices.
>
> Alan Weiss
> MATLAB mathematical toolbox documentation


Hi,
there's no error message. It's more a general question.
Ok, so, in the first case, p(2) is basically present in both equations (fit(1,:) and fit(2,:)) except that it is multiplied by a factor (0). My question now is if p(2) is also considered by the fitting routine in fit(1,:) or (as it should be) only in fit(2,:)?
I hope I made myself clear.
Thanks,
Pascal



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.