function a = avg(x,years,yr1,yr2)

a = 0;

nt = length(years);

count = 0;

for n=1:nt

   if( (years(n)>=yr1) && (years(n)<=yr2) )

      count = count+1;
      a = a+x(n);
   end
end

a = a/count;

