Home > chronux > fly_track > FAnalyze > functions > CalcReorientAngle.m

CalcReorientAngle

PURPOSE ^

CALCREORIENTANGLE

SYNOPSIS ^

function beta = CalcReorientAngle(vtheta, moves_indx)

DESCRIPTION ^

CALCREORIENTANGLE
   Usage:  beta = CalcReorientAngle(vtheta, moves_indx)

 This function calculates the reorientation angle, or the change in angle 
 of progression after the fly stops. The inputs are the angle of the 
 velocity vector, vtheta, and an index of all the frames where the fly was
 moving, moves_indx.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function beta = CalcReorientAngle(vtheta, moves_indx)
0002 
0003 %CALCREORIENTANGLE
0004 %   Usage:  beta = CalcReorientAngle(vtheta, moves_indx)
0005 %
0006 % This function calculates the reorientation angle, or the change in angle
0007 % of progression after the fly stops. The inputs are the angle of the
0008 % velocity vector, vtheta, and an index of all the frames where the fly was
0009 % moving, moves_indx.
0010 
0011 %Written by Dan Valente
0012 %modified November 2007
0013 
0014 m = 1;
0015 before = 0;
0016 
0017 for i = 1:length(moves_indx)-1
0018     if (moves_indx(i)+1 ~= moves_indx(i+1))
0019         beta(m) = 180*(vtheta(moves_indx(i))-before)/pi;
0020         if (beta(m) > 180)
0021             beta(m) = beta(m)-360;
0022         elseif (beta(m) < -180)
0023             beta(m) = beta(m)+360;
0024         end
0025         before = vtheta(moves_indx(i+1));
0026         m = m+1;
0027     end
0028 end
0029 
0030 return;

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005