Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Indexing Maximum Values from 3-D Matrix

조회 수: 4 (최근 30일)
Vesp
Vesp 2016년 12월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Image Analyst
Image Analyst 2016년 12월 9일
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?

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by