% César Sousa
% 28-10-2015

%Calculate the maximum speed give the time and position arrays

function velocity = calculateSpeed(imputMat)

    dif = abs(diff(imputMat(:,2)));
    
    posMaxVel = find(dif == max(dif));
    
    deltaTime = imputMat(posMaxVel+1,1) - imputMat(posMaxVel,1);
    deltaPos = imputMat(posMaxVel+1,2) - imputMat(posMaxVel,2);
    velocity = abs(deltaPos/deltaTime )/1000;

end