[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very basic question

From: pben
Subject: Re: Very basic question
Date: Wed, 30 Jul 2003 15:51:02 -0500

Hello Uli,

You are running into a fundamental issue with matrices.

If you multiply matrix A by matrix B, then their "inner" dimensions must be the same. That is, the number of columns in A must equal the number of rows in B.

If what you want is the "inner product" or "dot product" of two _vectors_, then you must stay aware as to whether the vectors are row or column vectors (actually in Octave and Matlab there are no vectors, just matrices made with a single row or single column).

You could get a result using a transpose

a * b'

Then the results would be 1*1+2*2+3*3=14

Or you could get a result using an element by element multiply

a .* b

Then the result would be a 1 x 3 (1 row, 3 cols) equal to [ 1*1 2*2 3*3] = [1 4 9]

Hope this helps,

Inactive hide details for Ulrich Grassberger <address@hidden>Ulrich Grassberger <address@hidden>

          Ulrich Grassberger <address@hidden>

          07/30/2003 03:42 PM

To: Octave mailing list <address@hidden>
Subject: Very basic question


when I type
a = [1,2,3]
b = [1,2,3]
a * b

Octave tells me
error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3)
error: evaluating binary operator `*' near line 3, column 3


works. Oh yeah!




Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

GIF image

reply via email to

[Prev in Thread] Current Thread [Next in Thread]