[EDIT: Thu May 12 22:17:54 UTC 2011 Duplicate Removed, Reformat – MKF]
Okay so I can't seem to find this last error in my program. I just get a constant loop.
My first function file for Consumers reads:
function F = Consumer2(x) %f1=N
%f2=n
%f3=k
global a R K W B w rf1= (a*W)/(R*K + W*x(1) - x(3))+(a-1)/(1-x(1));f2= B*((a*w)/(r*x(3) + w*x(2))+((a-1)/(1-x(2))));f3= (-a/(R*K + W*x(1) - x(3))) + B*((a*r)/(r*x(3) + w*x(2)));F= f1^2 + f2^2 + f3^2;endThe second function file for firm profit reads:function F = Firm2(x) %F1=N
%F2=n
%F3=k
global p r w K WF1=.6*p*(K^.3)*((x(1))^-.4)-W;F2=.6*p*((x(3))^.3)*((x(2))^-.4)-w;F3=.3*p*((x(3))^-.7)*((x(2))^.6)-r;F = F1^2 + F2^2 + F3^2;end
Finally my executable is:
global a R K W p B r wa=2/3;R=.1409;K=2;W=.8;p=1;B=.95;r=.5;w=.7;diff=1;diff1=0;diff2=0;diff3=0;while diff>.001NCons=fminsearch('Consumer2',[.2,.1,.5])NFirm=fminsearch('Firm2',[.2,.1,.5])diff1=NCons(1)-NFirm(1);W=W-.05*diff1;diff2=NCons(2)-NFirm(2);w=w-.05*diff2;diff3=NCons(3)-NFirm(3);r=r-.05*diff3;diff=diff1^2+diff2^2+diff3^2;end
When I run the executable i get an infinite loop. Any help?
Best Answer