function [chosenrow,chosencol]=recursive_search_for_balanced_bootstrap(ordered_array,num_bootstrap_runs,len) candidaterow=ceil(rand*num_bootstrap_runs); candidatecol=ceil(rand*len); if ~isnan(ordered_array(candidaterow,candidatecol)) chosenrow=candidaterow; chosencol=candidatecol; else [chosenrow,chosencol]=recursive_search_for_balanced_bootstrap(ordered_array,num_bootstrap_runs,len); end