cant get a good fit

조회 수: 4 (최근 30일)
Thaer Ismail
Thaer Ismail 2020년 1월 8일
답변: Walter Roberson 2020년 1월 8일
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
Capture.JPG
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
Thaer Ismail
Thaer Ismail 2020년 1월 8일
Even using simple forms doesnt work
F = @(x,xdata) exp(x(1)+x(2)*xdata)
x0 = [10 10]
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,Sw,H)
%
Capture.JPG
output =
struct with fields:
firstorderopt: 4.2501
iterations: 26
funcCount: 81
cgiterations: 0
algorithm: 'trust-region-reflective'
stepsize: 7.9310e-04
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.↵↵'

댓글을 달려면 로그인하십시오.

답변 (2개)

Robert U
Robert U 2020년 1월 8일
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
Walter Roberson 2020년 1월 8일
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.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by