how can I add a vector to a matrix in matlab?

matlab

Solution

An alternative to `bsxfun` is to use `repmat` and repeat the column vector `v` as many times as `A` has columns:

A = [1 2 3; 4 5 6; 6 7 8];
v = [1; 2; 3]

A = A + repmat(v,1,3);

Problem

How can I add a vector to a matrix in Matlab, in a manner that the i's index of the vector would be added to all the members in the i's row? for example: ``` A = [1 2 3; 4 5 6; 6 7 8] v = [1; 2; 3] ``` the required result is: ``` [2 3 4; 6 7 8; 9 10 11] ``` Thanks a lot.

Original source