help-octave
[Top][All Lists]
Advanced

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

Re: simple (not for me) operation on matrix


From: Quentin Spencer
Subject: Re: simple (not for me) operation on matrix
Date: Tue, 13 May 2003 09:29:05 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030430 Debian/1.3-5

Here's a quick solution, but there may be a more efficient way that
avoids the FOR loop using something like 'reshape':

N = size(big_matrix,1);

for n = 1:N/2
    new_matrix(n,:) = sum(big_matrix([n*2-1,n*2],:));
end




Paolo Ariano wrote:

hi *

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)

i'm coming crazy for such a simple thing, any idea ?

thanks
paolo





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