Element by Element Division
Element by element division (the dot division) ./
works differently from Array multiplication /
be careful not to confuse the two.
Division of Scalars
When we looked at subtraction we seen that 6 pens were used. If this is over a period of 3 months, we may want to know the amount of pens used each month so we can make a monthly order. To do this we can use division.
6 pens ./ 3 months = 6/3 pens/month = 2 pens/month
i.e. we see that 2 pens are used per month.
To write this in MATLAB we would use
6./3
Note for a 1 by 1 scalar array division and element by element division are identical.
(Dot Division) of a Column Vector
If 6 pens and 3 pads were used up in 3 months then
i.e. we see that 2 pens and 1 pad are used per month.
To write this in MATLAB we would use
[6;3]./[3;3]
(Dot Division) of Matrices
If the man in the red house used 6 pens and 2 pads up in a period of 3 months and the women in the green house used up 8 pens and 6 pads in a period of 4 months then
i.e. we see that the man uses 2 pens and 1 pad per month and the woman also uses 2 pens and 1 pad per month.
To write this in MATLAB we would use
[6,8;3,4]./[3,4;3,4]