tl = [4,4];
tr = [6,4];
bl = [4,2];
br = [6,2];

xs = [tl(1),tr(1),bl(1),br(1)];
ys = [tl(2),tr(2),bl(2),br(2)];
figure();
scatter(xs,ys);
xlim([0,8]);
ylim([0,8]);
hold on

cursor1 = [5,1];
cursor2 = [5,5];
cursor3 = [3,3];
cursor4 = [7,3];
cursor5 = [5,3];

data = [cursor1; cursor2; cursor3; cursor4; cursor5]

xs2 = [cursor1(1), cursor2(1), cursor3(1), cursor4(1)];
ys2 = [cursor1(2), cursor2(2), cursor3(2), cursor4(2)];

scatter(xs2,ys2)
scatter(cursor5(1), cursor5(2));

for i = 1:size(data,1)
    dummy = data(i,:)
    is_in_x = dummy(1) > bl(1) & dummy(1) < br(1);
    is_in_y = dummy(2) > bl(2) & dummy(2) < tl(2);
    is_in = dummy(1) > bl(1) & dummy(1) < br(1) ...
    & dummy(2) > bl(2) & dummy(2) < tl(2);
if is_in == 1
disp(strcat('point', num2str(i),' is in'));
else
disp(strcat('point', num2str(i),' is out'));
end
    
end

