Hello,
Yes: this should do it. Thank you in advance for your help!
Is1 = rand(1:3,3,3,3,5);
Pis1 = rand(3,3,3,5);
Is2 = rand(1:3,3,3,3,5);
Pis2 = rand(3,3,3,5);
X = rand(3,3,3,3,5);
function compute_cont(X, I1, I2, PI1, PI2)
I1_next, I2_next = min(3, I1+1), min(3, I2+1);
output = @views X[:, :, I1, I2, :] * PI1 * PI2 + X[:, :, I1_next, I2, :] * (1 - PI1) * PI2 + X[:, :, I1, I2_next, :] * PI1 * (1 - PI2) + X[:, :, I1_next, I2_next, :] * (1 - PI1) * (1 - PI2);
return output
end
for i = 1:3
for j = 1:3
for k = 1:3
for w = 1:5
# relevant continuation value
I1, PI1, I2, PI2 = Is1[i,j,k,w], Pis1[i,j,k,w], Is2[i,j,k,w], Pis2[i,j,k,w];
Xcont = compute_cont(X, I1, I2, PI1, PI2);
# some other operations occur on Xcont
end
end
end
end