MATLAB: How can i multiply every row to row values

MATLABmatrix

I am looking for a way to multiply one row values with every row values.
Let's assume we have:
A=[1 2 3;
4 5 6;
7 8 9]
B=[a b c]
I am looking for a way to have:
C=[1*a 2*b 3*c;
4*a 5*b 6*c;
7*a 8*b 9*c]
Thanks in advance for your comments.

Best Answer

>> A=reshape(1:9,3,[])
A =
1.00 4.00 7.00
2.00 5.00 8.00
3.00 6.00 9.00
>> B=1:3;
>> A.*B
ans =
1.00 8.00 21.00
2.00 10.00 24.00
3.00 12.00 27.00
>>
Works after TMW implemented automagic vector expansion -- I don't recall which release but has been a few cycles now.
If the above doesn't work on your version, use bsxfun