help-octave
[Top][All Lists]
Advanced

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

Removing For Loops


From: dirac
Subject: Removing For Loops
Date: Tue, 3 Aug 2010 04:13:21 -0700 (PDT)

I have been trying to think how to remove a for loop in my code for a while
and have run out of ideas! Basically I have a vector A and I want to create
a matrix such that:



for i = 1:length(A)
B = [A(i+1)-A(i), (A(i+1)+A(i))/2)]   %this will be two columns, the first
is the difference and
end                                            %the second the mean of the
two elements used for the diff.



Is there a way to 'vectorize' this or would it be unnecassary to do so?
Many thanks in advance.
Martin

-----
Pretty much convinced Octave>Excel for scientific data analysis!
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Removing-For-Loops-tp2311651p2311651.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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