Problem 57540. Repeatitive Summation

Given numeric vectors x, a and b, perform the following operation -
a represents a vector of numbers and b represents a vector of indices; corresponding to the values in b, add the values of a to x.
Examples -
Input
x = [1 2 3 4]
a = [1 2 3]
b = [1 2 1]
Output
y = [5 4 3 4]
Explaination - Add a(1) to x(b(1)), a(2) to x(b(2)) and so on.
Input
x = [3; 5; 7; 9]
a = [-2; 0; 2]
b = [4; 4; 1]
Output
y = [5; 5; 7; 7]
Note - Values in x and a will belong to Real numbers, values in b will be Integers in the range [1, numel(x)]. Test suite will be updated regularly.
Restrictions - loops and recursion are not allowed.

Solution Stats

47.83% Correct | 52.17% Incorrect
Last Solution submitted on Nov 25, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers7

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!