MATLAB: Fastest way to AND or OR together columns of a matrix

jitlogical operationMATLABoptimization

I'm using 2017b and I need to test whether each row of a matrix meets an inequality constraint. This test is done millions of times in my code, so I'm trying to make it as fast as possible. I'm wondering if there is any faster way to do it than this
testdata = rand(1000,26); % setup some fake data
testref = rand(1,26)/20; % setup a fake test reference
result = sum(testdata >= testref,2)==26; % Actual test; can this be faster?

Best Answer

try
result = all(testdata >= testref,2)
It is quite faster.
Elapsed time is 0.000445 seconds.
Elapsed time is 0.000294 seconds.
Elapsed time is 0.000426 seconds.
Elapsed time is 0.000254 seconds.
Elapsed time is 0.000406 seconds.
Elapsed time is 0.000255 seconds.