Is A==0 really better than ~A?
This is not strictly an answer but rather my contribution to the discussion I used the profiler to investigate a slightly-modified version of your code: N_arr = 200:400:3800; %// for medium to large sized input array for k1 = 1:numel(N_arr) A = randi(1,N_arr(k1)); [~]=eq(A,0); clear A A = randi(1,N_arr(k1)); [~]=not(A); clear A end I used … Read more