MATLAB Answers

0

Finding maximum value and corresponding variable

Asked by Mohammad Sohel Rana on 24 Jun 2019
Latest activity Commented on by Mohammad Sohel Rana on 24 Jun 2019
Dear Matlab expert
P(m,d,L) is a matix and size of P(m,d,L) is [10 40 10]. Total element =10*40*10=4000;
Now I need to find maximum value(one maximum value) for P and corresponding m,d,L.
I am expecting your kind help.
Kind regards
Sohel

  0 Comments

Sign in to comment.

1 Answer

Answer by the cyclist
on 24 Jun 2019
 Accepted Answer

P = rand(10,40,10); % Some pretend data
[P_max,linear_index_max] = max(P(:)); % Find max and index, for linearized matrix
[mc,dc,Lc] = ind2sub([10 40 10],linear_index_max); % Convert the linear index to subscripts

  1 Comment

Sign in to comment.