<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245542</link>
    <title>MATLAB Central Newsreader - replacing NaN based on a specific moving window</title>
    <description>Feed for thread: replacing NaN based on a specific moving window</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 27 Feb 2009 21:32:01 -0500</pubDate>
      <title>replacing NaN based on a specific moving window</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245542#631405</link>
      <author>Kuo-Hsien </author>
      <description>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).&lt;br&gt;
&lt;br&gt;
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.)&lt;br&gt;
&lt;br&gt;
Here is the bone of question I like to deal with:&lt;br&gt;
&lt;br&gt;
values = rand(1,1000)';&lt;br&gt;
fake_NaN = floor(rand(1,300)'*1000);&lt;br&gt;
values(fake_NaN) = NaN;&lt;br&gt;
for i = 1:length(values)&lt;br&gt;
n = 24 * i * (1:5)&lt;br&gt;
having_nan_index = find(isnan(values))  &lt;br&gt;
new_values = nanmean(values(having_nan_index * n-1:having_nan_index*n+1))&lt;br&gt;
:&lt;br&gt;
Something like that&lt;br&gt;
:&lt;br&gt;
&lt;br&gt;
If you have any solutions, advices and tips, please feel free to let me know.&lt;br&gt;
&lt;br&gt;
Thanks, Michael</description>
    </item>
    <item>
      <pubDate>Fri, 27 Feb 2009 21:42:00 -0500</pubDate>
      <title>replacing NaN based on a specific moving window</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245542#631410</link>
      <author>Image Analyst</author>
      <description>Kuo-Hsien, Michael&lt;br&gt;
Take a look at the convolution function, conv.  I'm not sure but maybe it will ignore nan's and give you the means.  If it does, then just find the nan's in the original matrix and replace them with the values from the convolved matrix.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Mon, 02 Mar 2009 19:50:17 -0500</pubDate>
      <title>replacing NaN based on a specific moving window</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245542#631980</link>
      <author>Kuo-Hsien </author>
      <description>Thanks for the tip, but it seems the one I want. Michael&lt;br&gt;
&quot;Image Analyst&quot; &amp;lt;imageanalyst@mailinator.com&amp;gt; wrote in message &amp;lt;go9mn8$sot$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Kuo-Hsien, Michael&lt;br&gt;
&amp;gt; Take a look at the convolution function, conv.  I'm not sure but maybe it will ignore nan's and give you the means.  If it does, then just find the nan's in the original matrix and replace them with the values from the convolved matrix.&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Mon, 02 Mar 2009 19:59:01 -0500</pubDate>
      <title>replacing NaN based on a specific moving window</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/245542#631981</link>
      <author>Kuo-Hsien </author>
      <description>I'm referencing these two tips to deal with it. Thanks, Michael&lt;br&gt;
1. ndnanfilter.m&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/20417&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/20417&lt;/a&gt;&lt;br&gt;
2. moving_average v3.1&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/12276&quot;&gt;http://www.mathworks.com/matlabcentral/fileexchange/12276&lt;/a&gt;</description>
    </item>
  </channel>
</rss>

