[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Yet Another Vectorization Problem
From: |
dirac |
Subject: |
Yet Another Vectorization Problem |
Date: |
Mon, 19 Jul 2010 08:17:41 -0700 (PDT) |
Hi everyone,
This is another vectorization problem. I understand that there have been a
few of these problems on here recently and I have read them but seem to get
no furthur with my particular code...
I have the data set with 10002 rows and 21 columns. Basically I read inthe
matrix and then define other data sets/vectors from the data read in. I then
want to take a moving average (I think it's called that!) for the new vector
named data (which is 10001x20 in dimensions). What I am doing is using the
sum function for calculate a mean value for the first 1000 data points for
all 20 columns. I then want to move on to the data points between 2 and
1001; then 3 and 1002 etc...
My code reads as follows:
function av=aver(filename)
f = dlmread(filename); %read in the file to be analysed
lambda = f(2:length(f),1); %this is the 1st column from the file
data = f(2:length(f),2:21); %this is the 2nd to 21st columns from the
file
av=[] Defining the running mean as a matrix.
for i = 1:1:9001
av(i,:) = [(sum(data(i:999+i,:),1))/1000]; %the data(i:999+i,:) bit is
doing what I described above
end
end
The problem is is that it seems to run very slowly looping 9001 times and I
have never actually finished running it! And a nieve quiestion is can there
be a faster way?
Thanks in advance :)
Martin
-----
Pretty much convinced Octave>Excel for scientific data analysis!
--
View this message in context:
http://octave.1599824.n4.nabble.com/Yet-Another-Vectorization-Problem-tp2294167p2294167.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Yet Another Vectorization Problem,
dirac <=
- Prev by Date:
Re: Control toolbox having ss2tf, tf2ss, ss2sys, tf2sys, lsim, etc missing
- Next by Date:
help on non-existing entry segfaults
- Previous by thread:
Control toolbox having ss2tf, tf2ss, ss2sys, tf2sys, lsim, etc missing
- Next by thread:
Re: Yet Another Vectorization Problem
- Index(es):