- #1

- 60

- 0

## Homework Statement

The following notation is as follows: a comma ',' represents a column and a semi-colon ';' represents a new row.

I have a vector:

A = [a1, a2, a3, a4, a5]

and a matrix

B = [b1, b2, b3, b4, b5;

b6, b7, b8, b9, b10;

b11, b12, b13, b14, b15]

What I want is:

C = [a1*b1, a2*b2, a3*b3, a4*b4, a5*b5;

a1*b6, a2*b7, a3*b8,a4*b9, a5*b10;

a1*b11, a2*b12, a3*b13, a4*b14, a5*b15]

Basically, each row of B needs to be multiplied with A element-wise.

## Homework Equations

Just some basic matrix math.

## The Attempt at a Solution

I'm doing this in matlab (which does matrix math much faster than loops). I can only think to do a for loop for the number of rows in B, and doing an element-wise multiplication of A and the current row of B. But The number of rows in B is actually quite large and would cause the program to run much slower than I'd like.