Suppose C_sub was created
C_sub = C(rows,cols);
where rows and cols are index vectors. Save those rows and cols vectors somewhere, you can reuse them if you haven't already.
[max_C_sub, ind_C_sub] = max(C_sub(:)); [ypeak_sub, xpeak_sub] = ind2sub(size(C_sub), ind_C_sub); xpeak = cols(xpeak_sub); ypeak = rows(ypeak_sub);
Or, if rows and / or cols was a vector of logical elements instead of an index vector, you can convert them using find and then proceed as described above.
rows_ind = find(rows_logical);
aschepler
source share