function [dataout] = interp_data(s,data);

Nmax = max(size(data));

for i=1:(Nmax-1);
    if data(i,3) <= s
        if s <= data(i+1,3)
            break;
        end;
    end;
end;
%i
if i == (Nmax -1)
    %'shit'
    dataout = data(i+1,1:2);
else
    ds1  = s -data(i,3);
    ds2 = data(i+1,3)-data(i,3);

    if ds2 == 0 
        dataout = data(i,1:2);
    else 
        ds3 = ds2-ds1;
        dataout = ds3*data(i,1:2)/ds2+ds1*data(i+1,1:2)/ds2;    
    end;
    
end;    


        