help-octave
[Top][All Lists]

## RE: simple (not for me) operation on matrix

 From: Ted Harding Subject: RE: simple (not for me) operation on matrix Date: Tue, 13 May 2003 17:16:15 +0100 (BST)

```On 13-May-03 Paolo Ariano wrote:
> ive a big matrix (750 cols* 140 rows) for example:
>
> 1 2 3 2 4 5 6
> 3 4 6 5 3 2 1
> 2 4 5 6 7 8 8
> 6 7 5 4 3 2 1
>
> i need to obtain a new matrix where i sum line 1 and line 2, then line
> 3 and line 4 and so on as:
>
> (1+3) (2+4)
> (2+6) (4+7)

Hi Paolo,

octave:1> M=[
> 1 2 3 2 4 5 6
> 3 4 6 5 3 2 1
> 2 4 5 6 7 8 8
> 6 7 5 4 3 2 1
> ];
octave:2> L1=(1:2:3);L2=L1+1;
octave:3> M1=M(L1,:);M2=M(L2,:);P=M1+M2
P =

4   6   9   7   7   7   7
8  11  10  10  10  10   9

For your "big" problem (140 rows) just change "L1=(1:2:3);"
to "L1=(1:2:139);"

Best wishes,
Ted.

--------------------------------------------------------------------
Fax-to-email: +44 (0)870 167 1972
Date: 13-May-03                                       Time: 17:16:15
------------------------------ XFMail ------------------------------

-------------------------------------------------------------
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
-------------------------------------------------------------

```