[Top][All Lists]

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

Re: declaring a scalar

From: Paul Roberts
Subject: Re: declaring a scalar
Date: Mon, 9 Apr 2007 22:03:11 -0700

Ah yes. That is a good point. Octave will interpret the expression:

k + A

to mean that you want to add the scalar value of k to every element of
A, or k*ones(n) + A. This is different from the interpretation that k
+ A means k*eye(n) + A. I would argue however that the expression k +
A does not make much sense mathematically anyway.


On 4/9/07, Geordie McBain <address@hidden> wrote:
Yes, most of the time, but a little catch (which can be difficult to
debug) is that if k is a scalar, u a length n column vector, and A is an
n*n matrix, then sometimes mathematically we think k*u + A*u is the same
as (k+A)*u, but to get it in Octave we need (k*eye(n)+A)*u.

On Sun, 2007-04-08 at 16:36 -0700, Paul Roberts wrote:
> I believe that in octave, a 1x1 matrix is treated as a scalar, so you
> may write your code assuming that if you say x=2, then the variable x
> will behave like a scalar variable with value 2.
> Paul
> On 4/8/07, Vivek Rao <address@hidden> wrote:
> > x = 2
> >
> > creates a 1-by-1 matrix. How can I create a scalar
> > variable with value 2? Thanks.
> >
> > Vivek Rao

reply via email to

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