Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Indexing Maximum Values from 3-D Matrix

2 Ansichten (letzte 30 Tage)
Vesp
Vesp am 9 Dez. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello,
I have a 3-D matrix A for which I have sorted in descending order and cumulatively summed, so that I can extract the total sum defined by the top N values specific for each grid cell defined by Matrix A.
I am trying to index where the top N values came from in the 3D matrix, but I'm not sure how to approach this. Any help would be greatly appreciated.
Here is a sample of what I have done:
t = A10shapehist > 0;
[m,n,k] = size(A10IVT);
C = zeros(m,n); %create empty matrix
C0 = cumsum(sort(A10IVT,3,'descend'),3); %sort the values of each grid cell at 3rd dimension descending and sum
[ii,jj] = ndgrid(1:m,1:n);
C(t) = C0(sub2ind([m,n,k],ii(t),jj(t),A10shapehist(t))); %take cumulative sum values and store in C based on number of t(top AR values)
Final goal: Index where the top values C(t) came from in the 3D matrix so that I can extract the values from other matrices from that same location.
Thank you!!!
  1 Kommentar
Image Analyst
Image Analyst am 9 Dez. 2016
What do you mean by "top N values"? Does that mean the elements with the highest numerical values? Not like elements in the top plane does it? If so, then why are you simply not using sort()? sort() will give you both the sorted value and what index they live in.
[sortedValues, sortIndexes] = sort(A, 'descend');
I'm not sure what you mean by "specific for each grid cell defined by Matrix A." What is a "grid cell"? Is it simply an element of A?
What does A represent? You say A represents "grid cells", but grid cells of what? Exactly what do the elements of A refer to? Some other matrix?

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by