-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathvecvel.m
43 lines (40 loc) · 1.44 KB
/
vecvel.m
1
function v = vecvel(xx,SAMPLING,smoothtype)%------------------------------------------------------------% FUNCTION vecvel.m% Calculation of eye velocity from position data% Please cite: Engbert, R., & Kliegl, R. (2003) Microsaccades% uncover the orientation of covert attention. Vision Research% 43: 1035-1045.%% (Version 1.2, 01 JUL 05)%-------------------------------------------------------------%% INPUT:%% xy(1:N,1:2) raw data, x- and y-components of the time series% SAMPLING sampling rate (number of samples per second)% smoothtype 0: no smoothing% 1: 3-point smoothing % 2: 5-point smoothing (default) %% OUTPUT:%% v(1:N,1:2) velocity, x- and y-components%%-------------------------------------------------------------% modified by [email protected], Oct-1-2013 for EYE-EEG toolboxN = length(xx); % length of the time seriesv = zeros(N,2);if nargin<3 % default is 5-point smoothing smoothtype = 2;endswitch smoothtype case 0 % no smoothing v(2:N,:) = SAMPLING*diff(xx); case 1 % 3-point smoothing v(2:N-1,:) = SAMPLING/2*(xx(3:end,:) - xx(1:end-2,:)); case 2 % 5-point smoothing (default) v(3:N-2,:) = SAMPLING/6*(xx(5:end,:) + xx(4:end-1,:) - xx(2:end-3,:) - xx(1:end-4,:)); v(2,:) = SAMPLING/2*(xx(3,:) - xx(1,:)); v(N-1,:) = SAMPLING/2*(xx(end,:) - xx(end-2,:));end