A bit slow, but works great for my needs. If there is a optimal (faster) way of doing this, will someone please share.
Ran into a small issue with repeated values, where it returned more than one value, causing an error in my routine. This can be corrected on my end, but to do so in here, I just changed the code a little bit (as below):
if nargout==1 | nargout==0
if all(isinf(srcharray(:)))
r = [];
else
clear r_temp;
r_temp = find(abs(srcharray)==min(abs srcharray(:))));
if length(r_temp)>1
r = r_temp(1);
else
r = r_temp;
end
end
end