title: replace nan values with the mean of other rows
body: <p>Consider the following example:</p>
  
  <pre><code>Jday = datenum('2007-01-01 00:00','yyyy-mm-dd HH:MM'):1:...
      datenum('2009-12-31 23:00','yyyy-mm-dd HH:MM');
  Jday2 = datenum('2008-01-01 00:00','yyyy-mm-dd HH:MM'):1:...
      datenum('2010-12-31 23:00','yyyy-mm-dd HH:MM');
  
  Data{1} = [Jday;1+(length(Jday)-1).*rand(1,length(Jday))]';
  Data{2} = [Jday2;1+(length(Jday)-1).*rand(1,length(Jday))]';
  Data{3} = [Jday;1+(length(Jday)-1).*rand(1,length(Jday))]';
  
  for i = 1:length(Data);
      d_nan{i} = floor(1+(length(Jday)-1).*rand(1,100));
  end
  
  for i = 1:length(Data);
      a(i) = length(d_nan{i});
      for ii = 1:a(i);
          Data{i}(d_nan{i}(ii),2) = nan;
      end
  end
  </code></pre>
  
  <p>In this example I have a cell array 'Data' which contains three cell arrays, the first column of each cell array contains the Julian date of the value in the second column. There are numerous nan values in each cell array. I would like to replace the nan values in each cell array with the average of the values in the other cells for that specific julian date. My problem is complicated due to the three cells not showing data at the same times (although Data{1} and Data{3} have the same days.) If the julian date were identical between the three cells this problem could be solved by using isnan to find the location of the nans and then replace those rows by the nanmean of the other rows (in the other cells). </p>
  
  <p>Could anyone suggest an effective way of tackling this problem? Thank you for your time</p>