MATLAB: Concatenate arrays after performing addition

concatenatefor loopMATLAB

I'm trying to add all the elements of A with element 1 of B. then do it again with element 2 etc. I'd like to concatinate the four 3×3 arrays into one array D (3×12). But i'm getting error messages.
This test code does what i want with array C, but i'm struggling getting all the previous FOR loops of C and the concatenation
A = [1,2,3;4,5,6;7,8,9];
B = [2,3,4,5];
C = zeros(3);
D = zeros(3,12);
for i = 1:numel(B)
C = A + B(i)
end
Thanks for any assistance you give,
Neil

Best Answer

A = [1,2,3;4,5,6;7,8,9];
B = [2,3,4,5];
D = reshape(permute(A + reshape(B,1,1,[]),[2,1,3]),size(A,2),[])';