Tutorial Video
Addition of Scalars
Lets first look at the addition of scalars i.e. 1 by 1 matrices. Let's now for the sake of conceptualisation prescribe the values we have to objects. If we have 3 pens at home and order 5 more pens then when our order arrives we will have:
3 pens + 5 pens = 8 pens
To write this in MATLAB we would use
3+5
Addition of Column Vectors
Now let us conceptualise a more complicated example. Assume we have 3 pens and 2 pads at home, we then make a order for 5 more pens and 3 more pads.
Since pens and pads are separate objects we classify them as such. Let's essentially treat each item as a scalar:
3 pens + 5 pens = 8 pens
2 pads + 3 pads = 5 pads
If these are instead written as a column vector we will have:
To write this in MATLAB we would use
[3;2]+[5;3]
If I instead had 2 pens on my desk and I ordered 3 pads then in column vector notation I would have:
With this notation bare in mind that pens and pads are separate objects meaning a pen cannot transform into a pad and a pad cannot transform into a pen!
To write this in MATLAB we would use
[2;0]+[0;3]
Note how we have to use zeros here to denote that we don't have a pad or pen in the first and second column vectors respectively. Element by Element operations will only work if the Arrays have the same amount of Elements.
Addition of a Matrices
Okay so far, so good. Let's make things slightly more complicated now. Assume there are two neighbours, neighbour 1 lives in the red house and he has 3 pens and 2 pads, he makes an order for 5 pens and 3 pads and neighbour 2 lives in the green house and she has 2 pens and 2 pads, she makes an order for 7 pens and 5 pads. In this case after the order the man in the red house would have 8 pens and 5 pads whilst the woman would have 9 pens and 7 pads.
To write this in MATLAB we would use
[3,2;2,2]+[5,7;3,5]
Now obviously we can conceive of more complicated scenarios where there are say 5 neighbours and they each have and order 7 different item types of stationary which would give a 7 by 5 matrix opposed to the 2 by 2 case above.