MATLAB: How to perform an array multiplication for a vector and a matrix and output results as a matrix

array multiplication

Here is the problems and solution which seems very bad. Could anyone suggest a better solution?
M = [1 2 3];
C = [10 11 12; 13 14 15; 16 17 18; 19 20 21; 22 23 24];
K1=C(1,:).*M
K2=C(2,:).*M
K3=C(3,:).*M
K4=C(4,:).*M
K5=C(5,:).*M
B = vertcat(K1,K2,K3,K4,K5)

Best Answer

You might want this instead:
B = bsxfun(@times,C,M)