Depending on the density of 1s, but a for-loop (remember that?) might be the fatest
function BenchMax
A=rand(10000)>0.5;
tic
[~, I] = max(fliplr(A),[],2);
I = size(A,2) + 1 - I;
toc
tic
[m,n] = size(A);
I = zeros(m,1);
for r=1:m
for c=n:-1:1
if A(r,c)
I(r) = c;
break
end
end
end
I = n+1-I;
toc
end
0 Comments
Sign in to comment.