help-octave
[Top][All Lists]
Advanced

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

Re: adding vectors and matrices


From: Ted Harding
Subject: Re: adding vectors and matrices
Date: Fri, 22 Aug 1997 10:22:20 +0100 (GMT+0100)

( Re Message From: Andreas Heitmann )
> 
> I'm using octave for some time now, but I'm still wondering if there
> is a simple way to add a fixed column vector to a number of other
> column vectors stored in a matrix. Currently i'm using a loop like the
> following:
> 
>       v=[1;2;3];
>       for i=1:columns(x)
>               y(:,i)=x(:,i)+v;
>       endfor
> 
> Is it possible to compute y without a loop statement?

Hi,

      y = x + v*ones(1,columns(x));

will do it. I understand John Eaton plans to incorporate a syntax like

      y = x .+ v

for a future release which will do the same thing (and the corresponding
thing if v is a row vector with as many elements as x has columns, i.e.
add v to each row of x).

Best wishes,
Ted.                                    (address@hidden)

reply via email to

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