1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| clear all; close all; clc;
%% open Excel file, Extract data fly and Y-Maze
xyFly=xlsread('tracking fly.xlsm');
xyMt=xlsread('coordinate labyrinthe.xlsm');
%% coordinate Y-maze
xb= xyMt(:,1)'; %Rectangle on the bottom
yb= xyMt(:,2)';
xr= xyMt(:,4); %Rectangle on the right
yr= xyMt(:,5);
xl= xyMt(:,7); %Rectangle on the left
yl=xyMt(:,8);
xc=xyMt(:,10); %Triangle of the center
yc=xyMt(:,11);
xf= xyFly(:,1); %Coordinate of the fly (frame per frame)
yf= xyFly(:,2);
%% Function Inpolygon
[inb,onb]=inpolygon(xf,yf,xb,yb);
[inr,onr]=inpolygon(xf,yf,xr,yr);
[inl,onl]=inpolygon(xf,yf,xl,yl);
[inc,onc]=inpolygon(xf,yf,xc,yc);
%% To know how many point inside/outside (Useless in my case)
%numel(xf(in))
%numel(xf(on))
%numel(xf(~in))
%% Plot everything in one figure
figure
plot(xb,yb)
axis equal %([0 1390 0 1280]) % How to put the real resolution of the
%camera? to check!
hold on
plot(xl,yl)
plot(xr,yr)
plot(xc,yc)
plot(xf(inb),yf(inb),'b')
plot(xf(inr),yf(inr),'r')
plot(xf(inl),yf(inl),'g')
plot(xf(inc),yf(inc),'y')
%How to do, if one point is not in the maze but outside? which code?
hold off
%% do the test and know juste when is b,r,l or center
L= length(xyFly);
for R = 1:L
testb = inpolygon(xf,yf,xb,yb);
testl = inpolygon(xf,yf,xl,yl);
testr = inpolygon(xf,yf,xr,yr);
testc = inpolygon(xf,yf,xc,yc);
end
testfinal = [testb testl testr testc];
%testb(testb==0) = []; ==> supprime les 0 du vecteur
% regrouper tout sur un vercteur <260X1 logical> et changer les 1 de chaque
% test par leur lettre (b,l,r,c) |
Partager