MATLAB: How to multiply each row of a matrix with a second full matrix, while applying a formula

#matrixmultiplication

I want to multiply each row of 'a' into 'b' while applying a formula for each row of b, thus creating a new martix of size 8,4. Here is my code that's not working.
a=[3 4 5 1; 3 2 0 4]
b=[1 2 3 4;
2 0 2 4;
0 4 8 2;
2 1 0 4]
w=1
for s= 1:size(a,1)
for t= 1:size(b,1)
%updated formula%
new(w,:)= (3*a(1,1)+b(1,1)) + (5*a(1,2)+b(1,2)) +(a(1,3)+b(1,3)) + (5*a(1,4)+b(1,4)) %a formula
end
w=w+size(b,1)
end

Best Answer

a=[3 4 5 1; 3 2 0 4] ;
b=[1 2 3 4;
2 0 2 4;
0 4 8 2;
2 1 0 4] ;
M = [3 5 1 5] ;
iwant = cell(size(a,1),1) ;
for i = 1:size(a,1)
iwant{i} = M.*a(i,:)+b ;
end
iwant = cell2mat(iwant)