cant get a good fit
Show older comments
I cannot get a good fit. Attache is the data that I am using . Is there any other method to fit the data better
Thank you.
raw = xlsread('Dummy data canada'); % read in sheet number
Pc = raw(23:118,1);
Sw = raw(23:118,4)/100; %to convert Sw to fraction
plot(Sw,Pc,'ro')
F = @(x,xdata)1-x(1)*exp(-(x(2)./xdata).^(x(3)));
x0 = [-23124 0.3 -2.2];
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,Sw,Pc)
hold on
plot(Sw,F(x,Pc))
hold off

output =
struct with fields:
firstorderopt: 3.5903e+05
iterations: 16
funcCount: 68
cgiterations: 0
algorithm: 'trust-region-reflective'
stepsize: 2.0413
message: '↵Local minimum possible.↵↵lsqcurvefit stopped because the final change in the sum of squares relative to ↵its initial value is less than the value of the function tolerance.↵↵<stopping criteria details>↵↵Optimization stopped because the relative sum of squares (r) is changing↵by less than options.FunctionTolerance = 1.000000e-06.↵↵'
1 Comment
Thaer Ismail
on 8 Jan 2020
Answers (2)
Robert U
on 8 Jan 2020
Hi Thaer Ismail,
the following plot command is not correct:
plot(Sw,F(x,Pc))
According to your data handling it should be
plot(Sw,F(x,Sw))
resulting in expected fit-function outcome.
Kind regards,
Robert
Walter Roberson
on 8 Jan 2020
0 votes
My tests with other minimizers suggest that the values you are getting are within error tolerance of the best you can get with that model and that data.
If you construct the residue function then it is possible to differentiate with respect to x(1) and solve that for x(1), and then substitute, reducing the residue function to an equation of two variables -- so knowing x(2) and x(3) you can directly calculate the best x(1) . For the experimental values of x(2) and x(3) I was getting, the experimental x(1) value matched the optimum (so the search routines were working.)
Unfortunately it is not feasible to continue onward with differentiating the residue function of two variables. It is possible, though, to plot some points on its surface, to check to see if the experimental values are reasonable.
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!