I am trying such as following code. But it keeps giving "index exceeds matrix dimension error"
g=0.03; %gamma
b=0.45; %beta
a=0.3; %alpha
aa=2.5222; %1+alphabeta/beta
rho=0.5; %rho
r=1+rho*b/(1+a*b); %1+rho/1+alphabeta
th1=0.000045; %theta1
th2=0.000037; %theta2
R=900; %Resource
S=210; %S_-1
B=1/(1-a-g); %1/1-alpha-gamma
A02=1.5;A01=1.2;A12=1.9;A11=1.8;W=1;psi0=A02/A01;psi1=A12/A11;%%%%%%%%%
E0=[225 225,225 225];options=optimset('Display','iter');E=fsolve(@pl, E0, options)
%%pl.m function is
function F = pl(E)global W th1 th2 R rho a b g psi0 psi1F =[g/E(2,1)-(th1+W*th2)-(1+a*b)/b*(g/E(1,1)-(1+rho*b/(1+a*b))*(th1+W*th2));g/(psi1*E(2,1))-(1/W*th1+th2)-(1+a*b)/b*(g/(psi0*E(1,1))-((1+rho*b/(1+a*b))*(1/W*th1+th2)));R-(E(1,1)+E(1,2)+E(1,1)+E(2,2));E02-phi0*E(1,1); E12-phi1*E(2,1);psi0-psi1];
%%error message is
??? Index exceeds matrix dimensions.Error in ==> pl at 4F =[g/E(2,1)-(th1+W*th2)-(1+a*b)/b*(g/E(1,1)-(1+rho*b/(1+a*b))*(t1+W*th2));Error in ==> fsolve at 254 fuser = feval(funfcn{3},x,varargin{:});Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Best Answer