Time for action – doing multiplication operations

Let us try to perform some of the same operations for multiplication as we did for addition:

octave:75> a*a

ans = 4

octave:76> a*b

ans =
    2    4    6

octave:77> b*b

error:  operator *:  nonconformant arguments (op1 is 1x3, op2 is 1x3)

octave:78> b*c

ans = 14

What just happened?

From Command 75, we see that * multiplies two scalar variables just like standard multiplication. In agreement with linear algebra, we can also multiply a scalar by each element in a vector as shown by the output from Command 76. Command 77 produces an error—recall that b is a row vector which Octave also interprets as a 1 x 3 matrix, so we try to perform the matrix multiplication (1 x 3)(1 x 3), which is not valid. In Command ...

Get GNU Octave now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.