Sorry if the question if confusing, but I’ll make it clear here. What I’m looking to do is:
Suppose we have a vector (or a 1xN matrix) A= [a1 a2 a3 a4] and another B=[b1 b2 b3]
I want C to be:
[a1*b1 a1*b2 a1*b3
a2*b1 a2*b2 a3*b3
a3*b1 a3*b2 a3*b3
a4*b1 a4*b2 a4*b3]
Is there a command that will do so in matlab? I already have it done in a for loop, but considering the number of times the loop gets called, it will save up a lot of running time if I can manage to write it without the for loop.
Yes. It’s done with regular vector multiplication and is known as outer product. All you need to do is multiply a column vector with a row vector, in this case
A.' * B. Note thatAis transposed to make it a column vector (your is a row vector by definition).