The goal here is to find peaks in the xy plane. This is a general example but my particular utilization uses a much bigger dataset and is slower than I would like. Would vectorizing it help? Another method? I want there to be a thresholding.
[x,y,z] = peaks;prom = 1;% Find dimensions to set up loop
xdim = size(x,1);ydim = size(x,2);% Loop through x dimension to find peaks of each row
xpeaks = zeros(size(z));for i = 1:xdim [~,locs] = findpeaks(z(i,:), 'MinPeakProminence', prom); xpeaks(i,locs) = 1; end% Loop through y dimension to find peaks of each row
ypeaks = zeros(size(z));for i = 1:ydim [~,locs] = findpeaks(z(:,i), 'MinPeakProminence', prom); ypeaks(locs,i) = 1; end% Find indices that were peaks in both x and y
peak_inds = xpeaks+ypeaks == 2;% Plot
figurepeakshold onplot3(x(peak_inds),y(peak_inds),z(peak_inds),'r*','MarkerSize',24)
Best Answer