Octave: "sin(x)*cos(x); " brings back error

161 Views Asked by At

Good day,

I am having little trouble with Octave.

Description:

On octave I get following error when multiply tow moving indexes.

octave:103> x=[0 2 3 4 5 6 7 8 9]
x =

   0   2   3   4   5   6   7   8   9


octave:105> sin(x)*cos(x)
error: operator *: nonconformant arguments (op1 is 1x9, op2 is 1x9)
octave:106>

While on wolframalpha.com I get nice function:

sin(x)cos(2x); x=[0 to 9]

enter image description here

1

There are 1 best solutions below

0
On

You need to use ".*" instead of "*". The former is the pointwise multiplication, the latter is the vector/matrix/tensor multiplication.