MATLAB Answers

How to find the page of an array with it number/name and values, having max and min values as a whole page

1 view (last 30 days)
Shakir Hussain
Shakir Hussain on 18 Jun 2018
Commented: Jan on 20 Jun 2018
I have an array (10*8*12) and has find the page with its values and number, having max and min values as whole.
For example X (10*8*12) page number 5 (10*8) of array X has min value as whole same for max As we compare the matrix or subtract one from another A == B; z = A - B; In this case we do not need page number/name as we have two different single matrix.

  4 Comments

Show 1 older comment
Shakir Hussain
Shakir Hussain on 18 Jun 2018
As whole means not a specific value but compare the whole values of the pages and find min, max one with it number/name/address. e.g array(x) = 10*8*12 here max(x) means the page which has maximum values as whole(10*8) among as pages(12)
Rik
Rik on 18 Jun 2018
Can you give a small example (something like 2*3*4)? Am I understanding you correctly if I say you want to find the page containing the maximum value of the entire array?

Sign in to comment.

Accepted Answer

Jan
Jan on 19 Jun 2018
X = rand(10, 8, 12);
X(5, 6, 7) = 20; % The maximum
[maxValue, maxIndex] = max(X(:));
[i1, i2, i3] = ind2sub(size(X), maxIndex)
% i1 = 5
% i2 = 6
% i3 = 7 ==> this is the "page"

  4 Comments

Show 1 older comment
Shakir Hussain
Shakir Hussain on 20 Jun 2018
because it is directly getting the number from describe code (X(5, 6, 7) = 20; % The maximum). What ever we have (1....12) for i3 in the above code the result will be same it is.
Jan
Jan on 20 Jun 2018
@Shakir Hussain: "It is indexing only the first page of X" - it is not clear to me, what this means. The code finds the 3rd dimension, which contains the maximum value of the array.
Of course you will not set the element (5,6,7) to 20 in your real code. This was just an example to get a reproducible result.
X = rand(10, 8, 12);
[Value, Index] = max(X(:));
[i1, i2, i3] = ind2sub(size(X), Index)
Now i3 depends on the random data.
If this does not solve your needs, please give an explicit example of the inputs (with a 2x3x4 array) and the wanted output. Currently too much guessing is required to post a reliable answer.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags


Translated by