help-octave
[Top][All Lists]
Advanced

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

Re: Why is different ^ and .^?


From: Mike Miller
Subject: Re: Why is different ^ and .^?
Date: Mon, 23 May 2005 13:29:12 -0500 (CDT)

On Mon, 23 May 2005, Javier Arantegui wrote:

octave:7> a=0:1:10;
octave:8> a.^2
ans =

   0    1    4    9   16   25   36   49   64   81  100

octave:9> a^2
error: for A^b, A must be square
error: evaluating binary operator `^' near line 9, column 2

Why the second option (^ instead of .^) doesn't work? Shouldn't be easier if you could use the same operator as when you are working with an scalar? I'd be happy if you could provide me an explanation that I could give to my students.


a^2 means a*a
a.^2 means "square every element of a"

a^2  therefore requires that 'a' be a square matrix or scalar.
a.^2 does not require that 'a' have any particular dimensions

Mike



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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