Tutorial Video
Element by Element Multiplication
Element by element multiplication (the dot product)
works differently from Array multiplication
be careful not to confuse the two.
Multiplication of Scalars
Assuming one buys 5 pens and the price of a pen is £2. Then the amount of cash spent on pens is £10
To write this in MATLAB we would use
Note for a 1 by 1 scalar array multiplication and element by element multiplication are identical.
(Dot Product) of Column Vectors
If we ordered 5 pens which cost £2 each and 3 pads which cost £6 each then
i.e. we would spend a total of £10 on pens and £18 on pads.
To write this in MATLAB we would use
(Dot Product) of Matrices
If the man in the red house bought 5 pens and 3 pads and the women in the green house bought 7 pens and 5 pads from the same shop costing £2 a pen and £6 a pad then:
i.e. the man spent £10 on pens and £18 on pads and the woman spent £14 on pens and £30 on pads.
To write this in MATLAB we would use
Alternatively if the woman living in the green house went to a more expensive shop where the price of pens and pads was £3 and £7 respectively
i.e. the man would once again spend £10 on pens and £18 on pads and this time the woman would spend £21 on pens and £35 on pads.
To write this in MATLAB we would use