What does this fsolve error message mean: FSOLVE cannot handle non-square systems; switching to Gauss-Newton method?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Zoltán Csáti
am 25 Okt. 2014
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 Kommentare
Siehe auch
Kategorien
Mehr zu Manual Performance Optimization finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!