I am trying to simplify my code a bit, and I am across a small question. Let
v = [1; 2; 3]; a1 = [4; 5; 6]; a2 = [7; 8; 9]; A = [a1, a2];
I
yes, you can do this using bsxfun, for example:
u = bsxfun(@times,A,v);
or also by using repmat
repmat
u= repmat(v,[1 2]).*A;
or also by using kron
kron
u= kron(v,[1 1]).*A;
or last, just using matrix multiplication:
u = v*[1 1].*A;
I'm sure there are even more ways, but I'll stop here...