Home > data-analysis > modules > gaze > fixation_code > calVelocity.m

calVelocity

PURPOSE ^

This function calculate velocities based on cont_eye_x and cont_eye_y.

SYNOPSIS ^

function [velocity] = calVelocity(txy)

DESCRIPTION ^

 This function calculate velocities based on cont_eye_x and cont_eye_y.
 
 Inputs:   
    txy:    [time cont_eye_x cont_eye_y], N by 3
 
 Outputs:
   velocity:   velocity at each point in txy, N by 1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [velocity] = calVelocity(txy)
0002 
0003 % This function calculate velocities based on cont_eye_x and cont_eye_y.
0004 %
0005 % Inputs:
0006 %    txy:    [time cont_eye_x cont_eye_y], N by 3
0007 %
0008 % Outputs:
0009 %   velocity:   velocity at each point in txy, N by 1
0010 
0011 
0012 completionnum = size(txy,1);
0013 velocity = nan(completionnum, 1);
0014 
0015 for i = 2:completionnum
0016     velocity(i) = (sqrt(((txy(i,2) - txy(i-1,2))^2) + ...
0017         ((txy(i,3) - txy(i-1,3))^2))/(txy(i,1) - txy(i-1,1))); % calculates distance
0018     if (txy(i,1) - txy(i-1,1)) > 2
0019         velocity(i) = NaN;
0020     end
0021 end

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005