Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: replacing NaN based on a specific moving window
Date: Fri, 27 Feb 2009 21:32:01 +0000 (UTC)
Organization: CSU
Lines: 20
Message-ID: <go9m4h$jvs$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235770321 20476 172.30.248.35 (27 Feb 2009 21:32:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 27 Feb 2009 21:32:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 951788
Xref: news.mathworks.com comp.soft-sys.matlab:521391


Dear all, I'm dealing with gap filling on weather measurements which the NaN should be filled based on the time window of several days.(i.e., neighborhood hour of several days).

For example, one NaN at 5pm will be replaced by the mean value in the neighborhood hour of neighborhood several days. (let's say 4, 5 and 6pm of neighborhood 5 days.)

Here is the bone of question I like to deal with:

values = rand(1,1000)';
fake_NaN = floor(rand(1,300)'*1000);
values(fake_NaN) = NaN;
for i = 1:length(values)
n = 24 * i * (1:5)
having_nan_index = find(isnan(values))  
new_values = nanmean(values(having_nan_index * n-1:having_nan_index*n+1))
:
Something like that
:

If you have any solutions, advices and tips, please feel free to let me know.

Thanks, Michael