fitting a logarithmic data

5 views (last 30 days)
sally adin
sally adin on 8 May 2015
Answered: Ingrid on 8 May 2015
I wanted to fit my data of J and E with
lopt=fitoptions('Method','NonlinearLeastSquares','Lower',[1e-18 1e-12 -100 1e-75 0],'StartPoint',[1e-18 1e-12 -100 1e-75 0],'Upper',[1e-16 1e-10 0 1e-60 10])
lopt.DiffMinChange=1e-15; lopt.DiffMaxChange=1e5; mylfittype=fittype('b*exp(-c/x)+d*exp(f*x)','options',lopt) mylfit=fit(J,E,mylfittype,'-')
However I keep on getting an error message
Error using fit>iParseOptionalArgs (line 975) Algorithm options must be specified in a FITOPTIONS object or as property-value pairs.
What I am doing wrong. Also I want to fit another set of x and y with
fop=fitoptions('Method','NonlinearLeastSquares','Lower',[1e-5,1.5e-4],'StartPoint',[3e-5,1.6e-4],'Upper',[1.5e-4,1e-1]); myftype=fittype('0.024.*(log(x/a+1))+b*x','options',fop); myf=fit(Jrec,Vn,myftype) Jcoeff= coeffvalues(myf);
This does the fit but it gives me not a good one. I suscpect the method is not best for my data. I was interested in doing piecewise (which I was suggested) but I don't know how to.
Please help
  1 Comment
Michael Haderlein
Michael Haderlein on 8 May 2015
Please use the {}Code button top of the edit window to format your code in a readable manner. It's difficult to say anything about a code which is hardly readable.

Sign in to comment.

Answers (1)

Ingrid on 8 May 2015
since you are tring to do a nonlinear regression why don't you use nlinfit?
ownFunc = @(A,x) A(1)*exp(-A(2)/x)+A(3)*exp(A(4)*x);
A0 = ones(4,1); % provide good starting values appropriate for your case here
[beta,R,J,CovB,MSE,ErrorModelInfo] = nlinfit(J, E, ownFunc, A0);

Community Treasure Hunt

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

Start Hunting!