Info
この質問は閉じられています。 編集または回答するには再度開いてください。
lsqnonlin problem in R2012a
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to fit some data with lsqnonlin function for my Y=function(x1, x2, x3 amd X) where X and Z are experimentally obtained data while x1, x2 and x3 are parameters that I need to fit.
I did following: 1. I created my fit_simp.m file with content
function diff = fit_simp(x,X,Y)
diff = (x(1)+x(3)*x(3)*x(1)*x(2)*(x(1)+x(2))*X.^2)./(1+x(3)*x(3)*(x(1)+x(2))*(x(1)+x(2))*X.^2)- Y;
2. I created new m-file where I added my data for X, Y and initial conditions X0:
clear all
clc
X=[10000
11800
13600
15400
17200
19000
20800
22600
24400
26200
28000
29800
31600
33400
35200
37000
38800
40600
42400
44200
46000
47800
49600
51400
53200
55000
56800
58600
60400
62200
64000
65800
67600
69400
71200
73000
74800
76600
78400
80200
82000
83800
85600
87400
89200
91000
92800
94600
96400
98200
100000
];
Y=[228.79
221.66
217.28
215.53
210.89
206.81
205.8
203.89
200.27
199.39
197.57
196
194.15
193.66
191.52
190.2
188.94
189.03
186.92
187.15
185.23
184.28
184.11
183.23
183.08
181.5
181.07
180.22
180.28
180.28
178.82
178.08
177.89
177.12
176.9
176.94
176.55
175.54
175.05
173.84
174.43
174.04
173.36
173.58
172.69
172.76
172.5
172.21
172.24
171.78
171.59
];
% Initialize the coefficients of the function.
X0=[100 100 1e-9]';
And then I call solver and plot function:
[x,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(@fit_simp,X0,X,Y);
% Plot the original and experimental data.
Y_new = (x(1)+x(3)*x(3)*x(1)*x(2)*(x(1)+x(2))*X.^2)./(1+x(3)*x(3)*(x(1)+x(2))*(x(1)+x(2))*X.^2);
plot(X,Y,'+r',X,Y_new,'b')
The problem that occurs is that fitted data is very close to the initial conditions, very poor fitting. I can improve that only if I set better initial conditions but that is not what I would like to do because sometimes I am not sure what that values are... This is the response in the command window.
Local minimum possible.
lsqnonlin stopped because the size of the current step is less than
the default value of the step size tolerance.
<stopping criteria details>
I tried to optimize with
optimset('MaxFunEvals',15000);
optimset('Algorithm','levenberg-marquardt');
optimset('MaxIter',15000);
optimset('TolFun', 1.0000e-16);
optimset('TolX', 1.0000e-16);
before calling
[x,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(@fit_simp,X0,X,Y);
but there is no improvement. Any help?
0 件のコメント
回答 (2 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!