Hello,
I looked around and found similar questions that have been answered (here 1 and here 2) but not sure how to find the max y value at each x value and its index. It might contain ore than an index of there is two max values.
so, I need to find the max, its index so I can create related to the original data in Sorted_ENP
Thanks in advance.
x = round(Sorted_ENP(:,end),1);y = Sorted_ENP(:,end-1);[uv,~,idx] = unique(x);ymax = accumarray(idx,y,[],@max)ymax_idx = accumarray(idx,y,[],@(x) maxidx(x)) % how can i find the index of ymax
All_data = Sorted_ENP(ymax_idx,:) % i want the matrix after the max values have been selected.
function ymax_idx = maxidx(x) [~, ymax_idx] = max(x);end
Best Answer