From: Mohammad Monfared on
Hi everybody,

I'd like to do a curve-fitting job for two sets of function and data, simultaneously. That is: functions are: F1(x,t,u,z) & F2(x,u,z,w) ['x' is the only argument and the others are parameters to be found] and for each function we are provided with data sets: Xs and Ys. I'm going to find the values of the parameters to best fit the two data sets in the same time.
Is there any appropriate function in matlab or its toolboxes for this purpose or does any one know any trick?

thanks,
From: Sadik on
Hello Mohammad,

Have you looked at the Levenberg-Marquardt method? It does nonlinear least squares fitting. There is a function on Mathworks File Exchange [FEX] website:

http://www.mathworks.com/matlabcentral/fileexchange/16063-lmfsolve-m-levenberg-marquardt-fletcher-algorithm-for-nonlinear-least-squares-problems

I have also seen the same method being mentioned in the optimization toolbox but I have never used it.

As for the problem of fitting the two functions simultaneously, unfortunately I don't have a good idea...

Best.



"Mohammad Monfared" <gohardoust(a)gmail.com> wrote in message <hlpdj2$6nv$1(a)fred.mathworks.com>...
> Hi everybody,
>
> I'd like to do a curve-fitting job for two sets of function and data, simultaneously. That is: functions are: F1(x,t,u,z) & F2(x,u,z,w) ['x' is the only argument and the others are parameters to be found] and for each function we are provided with data sets: Xs and Ys. I'm going to find the values of the parameters to best fit the two data sets in the same time.
> Is there any appropriate function in matlab or its toolboxes for this purpose or does any one know any trick?
>
> thanks,
From: Mohammad Monfared on
"Sadik " <sadik.hava(a)gmail.com> wrote in message <hlpqhf$d1b$1(a)fred.mathworks.com>...
> Hello Mohammad,
>
> Have you looked at the Levenberg-Marquardt method? It does nonlinear least squares fitting. There is a function on Mathworks File Exchange [FEX] website:
>
> http://www.mathworks.com/matlabcentral/fileexchange/16063-lmfsolve-m-levenberg-marquardt-fletcher-algorithm-for-nonlinear-least-squares-problems
>
> I have also seen the same method being mentioned in the optimization toolbox but I have never used it.
>
> As for the problem of fitting the two functions simultaneously, unfortunately I don't have a good idea...
>
> Best.
>
>
thanks Sadik for your reply,

I've tried to solve this problem by minimizing the sum of norm2 values of the residual of data and each function, I mean the following function :

norm(F1(X1) - Y1) + norm(F2(X2) - Y2)

with 'fmincon' function. But I couldn't get any acceptable result. in fact no result when just fitting one function to the data set! while this is an easy job for 'lsqcurvefit' function. I wonder how 'lsqcurvefit' minimize the norm values?

anyway thanks again.
From: Sadik on
From the documentation, it seems that lsqcurvefit is minimizing the sum of squared errors.

Actually, if I were you, I would check two things:

1. Did I program the optimization correctly?
2. Why do you use fmincon? You don't have any constraints, right? So maybe you should use fminunc.

Best.



<hls569$nkb$1(a)fred.mathworks.com>...
> "Sadik " <sadik.hava(a)gmail.com> wrote in message <hlpqhf$d1b$1(a)fred.mathworks.com>...
> > Hello Mohammad,
> >
> > Have you looked at the Levenberg-Marquardt method? It does nonlinear least squares fitting. There is a function on Mathworks File Exchange [FEX] website:
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/16063-lmfsolve-m-levenberg-marquardt-fletcher-algorithm-for-nonlinear-least-squares-problems
> >
> > I have also seen the same method being mentioned in the optimization toolbox but I have never used it.
> >
> > As for the problem of fitting the two functions simultaneously, unfortunately I don't have a good idea...
> >
> > Best.
> >
> >
> thanks Sadik for your reply,
>
> I've tried to solve this problem by minimizing the sum of norm2 values of the residual of data and each function, I mean the following function :
>
> norm(F1(X1) - Y1) + norm(F2(X2) - Y2)
>
> with 'fmincon' function. But I couldn't get any acceptable result. in fact no result when just fitting one function to the data set! while this is an easy job for 'lsqcurvefit' function. I wonder how 'lsqcurvefit' minimize the norm values?
>
> anyway thanks again.
From: Mohammad Monfared on
You are right, the function to be minimized would be:

norm(F1(X1) - Y1)^2 + norm(F2(X2) - Y2)^2

and yes my parameters are constrained then I should use 'fmincon' . In addition to my previous attempt, now I've provided my function with the gradient, but still no acceptable answer.

"Sadik " <sadik.hava(a)gmail.com> wrote in message <hls744$gd7$1(a)fred.mathworks.com>...
> From the documentation, it seems that lsqcurvefit is minimizing the sum of squared errors.
>
> Actually, if I were you, I would check two things:
>
> 1. Did I program the optimization correctly?
> 2. Why do you use fmincon? You don't have any constraints, right? So maybe you should use fminunc.
>
> Best.
>