Hello all,
I have been looking for an efficient way to execute the following, but haven't come across anything in the forum. I would like to find the top N values in a multidimensional array at each grid cell of Matrix B (144x90x1877). I have found the following approach in the forum, but it gives the top N values for the entire multidimensional matrix.
n= 2; % any number specified
[a,ix] = sort(A(:),'descend'); a = a(1:n); ix = ix(1:n);
I would like to have the top N values for each grid cell be defined by another matrix(Matrix A, 2D matrix). For example, I would like to start with cell 1×1 matrix A which specifies 5 top N values so I go to Matrix B 1x1x8766 and sort the values in descending order and extract the top 5 values to be average and stored in another matrix. Continue with each cell.
I would appreciate any guidance on how to proceed with this. Thank you
Best Answer