How can I write this code faster in MATLAB? Maybe using vectorizations. Basically I do not know how to vectorize with if
for c=1:county_size
for w=1:scenario_size
for t=tt:time_size
l = u(c,t,w) ;
tprime = t ;
while (l==0)
if tprime > time_size-1
tprime = time_size + 1 ;
B(c,time_size + 1,w) = 0 ;
u(c,time_size + 1,w) = 1 ;
break
end
l = u(c,tprime+1,w) ;
tprime = tprime + 1 ;
end
benefit(c,t,w) = B(c,tprime,w)/u(c,tprime,w) ;
i(c,t,w) = tprime ;
end
end
end
Aucun commentaire:
Enregistrer un commentaire