フィルターのクリア

Coordinates of max in multidimensional arrays

4 ビュー (過去 30 日間)
Anita
Anita 2011 年 5 月 31 日
Dear Experts,
May I have some help? Being a beginner I got stocked with finding the coordinates of max values in a 3-dimensional array with respect to the 3rd dimension. I am trying to do this:
IND=max(val,[],3);
s=[2,61,1500];
[i,j,g]=ind2sub(s,IND)
where val is the original 3-D array and s is the size of val. For this I got the following error message:
??? Error using ==> rem Arguments must be real.
Error in ==> ind2sub at 35 vi = rem(ndx-1, k(i)) + 1;
I don't really see what should I do and I would very much appreciate any ideas...
thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2011 年 5 月 31 日
[themax,IND] = max(val,[],3);
That is, you were getting the maximum itself instead of its index.
  2 件のコメント
Anita
Anita 2011 年 5 月 31 日
thanks Walter, it is working now.
Anita
Anita 2011 年 6 月 1 日
May I have one more question? I got kind of a strange answer so I might have misunderstood what max with respect to a dimension means. May val matrix was generated by looping through the 3 dimensions, and what I need is to get the index of the max value in the matrix with respect to the 3rd dimension for each combination of the first two dimensions. This is like where is the max in each of 3rd-dim-"column", ie. for dim1=1 and dim2=1, for dim1=1 and dim2=2, etc. However, this command does something else because I don't get back my first-2-dim-combination indices going 1-by-1. What did I do wrong?

サインインしてコメントする。

その他の回答 (1 件)

KYAW KYAW
KYAW KYAW 2011 年 10 月 27 日
Dear Walter,
I would like to get the max of Y interms same X values. e.g X = [4 4 4 4 4 5 5 6 6 6....] Y = [10 11 12 13 24 25 34 24 23 ....]
I want to have X = [ 4 5 6 ...] Y = [24 34 24]
Only one X and one Y on the multiple of Y in terms of X
Pls advise me since I was stuck on it n need to finish up tomorrow.
Thankd and best regards Kyaw

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by