running the following code, with N = 1000000, never gives inpoly faster than inpolygon.For "small" N (N=100-1000), they alternate.
However, when running the examples provided in polydemo.m, inpoly is consistently faster than inpolygon.
Am I doing anything wrong? A graphical check (commented in the code) gives what seems to be right, so I think I'm using the function as I should. Anyway, I don't see any improvement in speed, the contrary (for large N).
%%% sample code %%%%%%
small_box = [ 1/3 1/3; 1/3 2/3; 2/3 2/3; 2/3 1/3];
N = 1000000;
A = rand(N,1);
B = rand(N,1);
% figure; hold on;
% patch([small_box(:,1); nan],[small_box(:,2); nan],ones(5,1))
tic; in = inpolygon(A,B,small_box(:,1),small_box(:,2)); t1=toc;
tic; in2 = inpoly([A B],small_box); t2=toc;
time_in_sec = struct('inpolygon',t1,'inpoly',t2);
fprintf('inpoly is %f seconds faster\n',t1-t2)
fprintf('inpolygon is %f seconds faster\n',t2-t1)