Predicting Mortality of ICU Patients: The PhysioNet/Computing in Cardiology Challenge 2012 1.0.0

function v = pinterp(variable,t,D)
% Pseudo Interp 
% This function returns the nearest neighbourgh if not too far   
    CandIdx = find( variable(:,1) > t-D/2 & variable(:,1) < t+D/2 );
    if ~isempty(CandIdx)
        [~,idx] = min( abs(( variable(CandIdx,1)-t )) );
        v = variable(CandIdx(idx(1)),2);
    else
        v = NaN;
    end