What does this fsolve error message mean: FSOLVE cannot handle non-square systems; switching to Gauss-Newton method?
14 次查看(过去 30 天)
显示 更早的评论
Warning: Default trust-region dogleg method of FSOLVE cannot handle non-square systems; switching to Gauss-Newton method. > In fsolve at 232 In homework5 at 11 Conditioning of Gradient Poor - Switching To LM method Optimization terminated: directional derivative along search direction less than TolFun and infinity-norm of gradient less than 10*(TolFun+TolX).
Script:
clear all
close all
global beta delta alpha K1 KS
beta=0.98;
delta=0.1;
alpha=0.33;
K1=4;
KS=(1/(beta*alpha)-(1-delta))^(1/(alpha-1));
xstart=KS*ones(299,1);
x=fsolve(@fname,xstart)
K(1)=K1
for i=2:286
x(i)=K(i+1);
end
for i=287:300
x(i)=KS;
end
plot(K(1:40))
Function:
function F=fname(x)
global beta delta alpha K1 KS
F(1)=1/(K1^(alpha)-x(1)+(1-delta)*K1)-beta*(alpha*x(1)^(alpha-1)+(1-delta))/(x(1)^alpha-x(2)+(1-delta)*x(1));
for i=2:285
F(i)=1/(x(i-1)^alpha-x(i)+(1-delta)*x(i-1))-beta*(alpha*x(i)^(alpha-1)+(1-delta))/(x(i)^alpha-x(i+1)+(1-delta)*x(i));
end
F(286)=1/(x(285)^alpha-x(286)+(1-delta)*x(285))-beta*(alpha*x(286)^(alpha-1)+(1-delta))/(x(286)^alpha-KS+(1-delta)*x(286));
I copied this script and it ran perfectly at the university. What does this error message mean?
0 个评论
回答(1 个)
Zoltán Csáti
2014-10-25
You set the vector of the initial solution to size 299 (so 299 number of unknowns are expected). However in the function definition fname you have only 286 entries meaning that the system is under-determined.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!