Find the maximum value and its position of a 10x10x10 matrix which meets a set of parameters.

3 ビュー (過去 30 日間)
I have a 10x10x10 matrix, M, which I found by taking 3 1x10 matrices, a b and c, and turning them into a 10x10x10 matrix, A, and then multiplied A by an unknown constant. I need to find the maximum value of M and its position while it's corresponding values of a, b and c are smaller than a set of parameters.
  4 件のコメント
Guillaume
Guillaume 2018 年 3 月 29 日
So if the max is found at (6,4,5) but the corresponding a,b,c don't fit the requirement, then what?
Jack Holland
Jack Holland 2018 年 3 月 29 日
I'm trying to find the biggest possible value which meets the requirement, so if the max doesn't fit then find the second biggest and if that doesn't fit then the third etc

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

採用された回答

Guillaume
Guillaume 2018 年 3 月 29 日
編集済み: Guillaume 2018 年 3 月 29 日
h = 70;
c = linspace(30,60,10);
b = linspace(1,h-2,10);
a = linspace(1,14,10);
[A, B, C]=meshgrid(a,b,c);
M = D *(C.*h-2*B.*A);
%Q = ...
%Fy = ...
isinrange= Q > Fy./(1/12*(C*h^3 - 2*A.B.^3));
[maxM, idx] = max(M(isinrange));
aAtMax = A(idx);
bAtMax = B(idx);
cAtMax = C(idx);
  3 件のコメント
Stephen23
Stephen23 2018 年 3 月 29 日
Guillaume defined the variable isinrange, whereas the error message shows that you apparently tried to use a non-existent name, isinrage (the mind boggles at what that variable would measure!)
Guillaume
Guillaume 2018 年 3 月 29 日
Saying that, the expression was missing a closing bracket (as does the original expression given in the original question). Now fixed.

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

その他の回答 (1 件)

Veera Kanmani
Veera Kanmani 2018 年 3 月 29 日
max_value_position=max(M);
max_value=M(max(M));
  4 件のコメント
Stephen23
Stephen23 2018 年 3 月 29 日
編集済み: Stephen23 2018 年 3 月 29 日
Given that M is a 10x10x10 array, max(M) will return a 1x10x10 array. Using that as the input to find will return as many indices as there are non-zero maximum values. If all of the values are non-zero then it will simply be a list of all linear indices of that 1x10x10 array. Lets try it with a smaller example:
>> M = rand(3,3,3);
>> find(max(M))
ans =
1
2
3
4
5
6
7
8
9
How does this list of all indices of non-zero values in the output of max help to solve the problem? How are we supposed to use these indices to "Find the maximum value and its position...", as the original question requests?
Jack Holland
Jack Holland 2018 年 3 月 29 日
max_value_position just returns a 100x1 matrix with numbers ranging from 1-100

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by