No loop necessary. You have all the infromation you need in ‘A’, ‘B’, and the index vectors:
C = A(Aind) + B(Bind)
C =
-10 37.5 -7.45 4.65
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!