N = 3000;

A = magic(N);

refNo = 100000;
vals = zeros(N^2,1);
ix = 1;
%%
tic
for i = 1:N
    for j = 1:N
        if A(i,j)>refNo
           vals(ix) = A(i,j);
           ix = ix+1;
        end 
    end
end

toc
%%

tic

vals  = A(A>refNo);

toc

%%
tic
vals = A(find(A>refNo));
toc