Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Indexing Maximum Values from 3-D Matrix
5 ビュー (過去 30 日間)
古いコメントを表示
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
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!