[Solved] Im looking for a way to add up elements of two arrays


My first thought is to do this with arrayfun using an anonymous function that adds each scalar element of a to the full array in b. Then since you get a cell array result you can expand that cell array into the array you are looking for:

>> a=[1,2,3,4], b=[5,6,7]
>> result = arrayfun(@(x) x+b, a,'UniformOutput',false);
>> result = [result{:}]

result =

     6     7     8     7     8     9     8     9    10     9    10    11

1

solved Im looking for a way to add up elements of two arrays