Path: news.mathworks.com!not-for-mail
From: "Ben" <basburywvu.nospam@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Nonuniform time moving window average
Date: Tue, 12 May 2009 19:20:02 +0000 (UTC)
Organization: Orbital Sciences Corp
Lines: 14
Message-ID: <guci52$fku$1@fred.mathworks.com>
Reply-To: "Ben" <basburywvu.nospam@hotmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1242156002 16030 172.30.248.38 (12 May 2009 19:20:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 12 May 2009 19:20:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 425457
Xref: news.mathworks.com comp.soft-sys.matlab:539397


I need to create a 1-second moving window average on a data array with a nonuniform time series.  The data and time vectors have dropouts (i.e no data recorded) and there are slight variations in the sampling rate (~100Hz).  So the number of points in each window should vary.  Below is a simplified example of what I am trying to do.  However this does not scale well and takes entirely to long when the data sets get large.  On average this would need to work on arrays ~200,000 samples in length.

time = 0:0.1:10;
time([5 25:28 45 60:62 90]) = []; %Simulated data drops
data = rand(size(time));
%Calc 1 second moving window average of the data.
windowAve = zeros(size(data));
for i = 1:length(time)
    windowAve(i) = mean(data(find(time >=time(i) & time< time(i)+1)));
end

Can anyone help me with a more efficient method.

Thanks