function y=lin_interp(vv,x)
                    #return an interpolation of matrix v=xi,vli,vri
                    #vli are values for x<xi, vri are values for x>=xi
  if x<vv(1,1)
    y=vv(1,2);
  elseif x>=vv(end,1)
    y=vv(end,3);
  else
    for i=1:size(vv,1)-1
       if (x>=vv(i,1)) && (x<vv(i+1,1))
         t=(x-vv(i,1))/(vv(i+1,1)-vv(i,1));
         y=vv(i,3)*(1-t)+vv(i+1,2)*t
         break;
       endif
    endfor
  endif
endfunction

  
