title: Matlab: sum for two time series dataset?
body: <p>I like to sum up the observations of two time series datasets when both of them have observations based on YEAR and DOY. I also like to skip the sum when either dataset has 0 and only do the sum for the maximum observation in that DOY.</p>
  
  <p>Here is the example: data_1 and data_2.</p>
  
  <h3>data_1</h3>
  
  <pre><code>% YEAR  DOY  OBS_1
  
  1994    109 0.42
  1994    110 0.73    
  1994    111 0.69    
  1994    113 0.8    
  1994    114 0.43    
  1994    115 0.75    
  1994    123 0.6    
  1994    127 0.2    
  1994    131 0.44    
  1994    131 0.43    
  1994    131 0.63    
  1994    132 0.99    
  1994    132 0.51    
  1994    133 0.71    
  1994    133 0.99    
  1994    134 0.65    
  1994    134 0.69    
  1994    134 0.97    
  1994    134 0.03    
  1994    134 0    
  1994    134 0    
  1994    135 0.68    
  1994    135 0.72    
  1994    136 1.22    
  1994    136 0    
  1994    136 0    
  1994    136 1.28    
  1994    136 1.34
  </code></pre>
  
  <h3>data_2:</h3>
  
  <pre><code>% YEAR  DOY  OBS_2    
  1994    110 0.92    
  1994    111 0.34    
  1994    113 0.42    
  1994    114 0.37    
  1994    115 0.38    
  1994    122 0.22    
  1994    127 0.32    
  1994    131 0.34   
  1994    131 0.2    
  1994    132 0.51    
  1994    132 0.43
  1994    132 0.4    
  1994    133 0.4    
  1994    134 0.32    
  1994    134 0.39    
  1994    135 0.35    
  1994    135 0.38    
  1994    135 0.34    
  1994    135 1.83    
  1994    135 0.22    
  1994    135 0.36    
  1994    135 0.39    
  1994    135 0.24    
  1994    135 0.39    
  1994    136 0.42    
  1994    136 0.29    
  1994    136 0.3    
  1994    136 0.4    
  1994    136 0.54    
  1994    136 0.4
  </code></pre>