Difficulty Solving for parameters of a non-linear curve fit to data

6 views (last 30 days)
Hello,
I have a data set that I am attempting to describe with a certain nonlinear equation of the following form
Y=2*(C1*exp(C2*(x/C3 - 1))+P1*P2*exp(((x/C3)-P3)/P4)^2)/x;
This fit has been used to fit data of a similar nature previous times, not by me of course. So there are four unknown parameters. Amongst these parameters I know that P1 must vary between 0 and 1 and all other parameters must be greater than 0. In most cases when determining the parameters I make use of matlabs fminsearch built in function and it works well. Yet this time my fit is horrible. If someone could help me out a little bit I would much appreciate it.
Pat
  4 Comments
Patrick
Patrick on 3 Sep 2013
Also that is a very good idea of combining the two unknown parameters. It is desired to eventually separate them, since they each represent different contributing phenomena.
Patrick
Patrick on 3 Sep 2013
Also on the file exchange with regards to this topic I did find a code titled fminsearchbnd

Sign in to comment.

Answers (2)

Shashank Prasanna
Shashank Prasanna on 3 Sep 2013
FMINSEARCH like most optimization algorithms are sensitive to initial guess or starting point. Did you try to provide different starting points? FMINSEARCH does not allow you to specify bounds or constraints on your parameters which may allow you to get better results.
The Curve Fitting Toolbox provides routines to fit curves that are better suited for such problems than FMINSEARCH and allows bounds of parameters.
You can also employ the Global Optimization Toolbox routines if you are unable to find a good starting points. Again you can also specify constraints.
Please provide more information about why your "fit is horrible" with some reproduction code and examples and we can assist you further.
  2 Comments
Patrick
Patrick on 3 Sep 2013
Hey Shashank,
Thanks for your response. I can't say as of yet that I have attempted different initial starting points. My reason is because I feel like my initial guesses make the most sense based upon previous data fits to other data and the constraints that I know the parameters must obey. I'll check both the curve fitting toolbox and the links which you have attached in the meantime, if you'd like here is my "code":
function Ves_fit
Pref=50;%{mmhg$} reference pressure for reference diameter
Dref=22.3;%{refernce diameter at reference pressure$}
Dia= [18 30 38 28 23 20 20 20 23 25];
Pres = [10 20 30 40 50 60 70 80 90 100];
bestcoeffs=fminsearch(@futen,[0.5 1 0.85 0.4],[],Dia,Pres);
yfit=2.*(62.1809.*exp(2.6830.*((Dia/Dref)-1))+bestcoeffs(1).*...
bestcoeffs(2).*exp(-(((Dia/Dref)-...
bestcoeffs(3))./bestcoeffs(4)).^2))./Dia;
%plot(Ca,REF,'o')
plot(Pres,Dia,'o')
hold on
plot(yfit,Dia)
%{%{%{%{%{%{%{%{%{%{%{%{%{%{%{%{
function out=futen(coeff,X,Y)
Pref=50;%{mmhg$} reference pressure for reference diameter
Dref=22.3;%{refernce diameter at reference pressure$}
a = coeff(1);
b = coeff(2);
c = coeff(3);
d = coeff(4);
%e = coeff(5);
%f = coeff(6);
%Y_fun will define for us our Pressure
Y_fun = 2.*(62.1809.*exp(2.6830.*((X/Dref)-1))+a.*b.*exp(-(((X/Dref)-...
c)./d).^2))./X;
DIFF = Y_fun - Y;
SQ_DIFF = DIFF.^2;
out = sum(SQ_DIFF);
dpb
dpb on 3 Sep 2013
Edited: dpb on 4 Sep 2013
This is truly bizarro...that kind of double-valued response is expected????
What's actually independent/dependent variable? One would think the pressure would be dependent upon some diameter but plotted 't other way round?
Seems strange at best...
But the other comments still hold and I've got to run--maybe can look into it more later.

Sign in to comment.


Matt J
Matt J on 4 Sep 2013
Edited: Matt J on 4 Sep 2013
If you transform your data according to
XX = x/C3
YY = Y- 2*(C1*exp(C2*(x/C3 - 1))
then your model can be simplified to
YY= t1*exp((t2*XX-t3).^2)/XX
with unknown parameters t1,t2,t3. If you take the log() of both sides of this, you obtain quadratic equations parametrized by log(t1), t2, t3 which can be solved for e.g., using POLYFIT. I wouldn't recommend deriving final solutions for t1,t2,t3 only from that, but it might serve as a more educated initial guess (cf. Shashank's remarks) when fed to fminsearch, lsqcurvefit, fminbnd, etc... than what you are doing now.
In addition to LSQCURVEFIT, you could also try
which would let you take advantage of the fact that YY has a linear dependence on t1.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!