MATLAB: I’m looking to eliminate the following for loop:

for loopMATLABvectorization

I'm looking to eliminate the following for loop:
for j=1:96
rn(ijk(j))=rn(ijk(j))+mp(j);
end
Background: rn is a 200x3x3 matrix, ijk is a 1800×1 matrix and np is a 12×8 matrix. ijk describes the mapping between mp and (the much larger) rn. For example, when j=1, mp(j)=0.84 and ijk(1)=601. This loop is embedded in a much larger loop.
There has got to be a way to eliminate the for loop presented here. Any suggestions?

Best Answer

Perhaps:
idx = 1:96;
rn(ijk(idx))=rn(ijk(idx))+mp(idx);