1234567891011121314151617181920212223242526272829303132333435363738 |
- function [angle] = ExtractAngleInfo(StartPoke,EndPoke,animal)
- %[angle] = ExtractAngleInfo(StartPoke,EndPoke,animal)
- % Extract angle info from a given start and end poke port, and a given
- % specis of animal(Mice or Rat)
- %
- % Examples:
- % ExtractAngleInfo('MidC','TopR','Mice')
- % ExtractAngleInfo('MidC','TopR','Rat')
- %
- Pokes = {'MidR','TopR','BotR','MidC','TopL','MidL','BotL','BotC','null'};
- if sum(strcmp(EndPoke,Pokes))==0
- Pokes = {'D','B','F','G','A','C','E','H'};
- end
- if strcmp(animal,'Rat')
- cord = [129,58;101,83;101,33;73,58;...
- 45,83;17,58;45,33;73,18;nan,nan];
- elseif strcmp(animal,'Mice')
- cord = [129,40;100,55;100,25;71,40;...
- 52,55;13,40;42,25;71,17;nan,nan];
- end
- StartPoke_cord = cord(strcmp(StartPoke,Pokes),:);
- EndPoke_cord = cord(strcmp(EndPoke,Pokes),:);
- goes = EndPoke_cord-StartPoke_cord; %[dx,dy]
- if goes(1)==0 && goes(2)>0
- angle = pi/2;
- elseif goes(1)==0 && goes(2)<0
- angle = -pi/2;
- elseif goes(2)==0 && goes(1)<0
- angle = -pi;
- elseif goes(1)<0
- angle = pi+atan(goes(2)/goes(1));
- else
- angle = atan(goes(2)/goes(1));
- end
- angle(angle<0) = angle + 2*pi;
- %angle = angle*180/pi;
- end
|