How to call out the original name of a value from an array?

2 views (last 30 days)
Hello,
I am pretty new to Matlab,Ive been working on a code that involves a matrix that is 9x17. I am trying to find the ultimate maximum value from 3 sepreate rows and display the value and location. Thank you for your time in advance.
[MRow_3, Mloc3]=max(T_d(3,:))
[MRow_5, Mloc5]=max(T_d(5,:))
[MRow_7, Mloc7]=max(T_d(7,:))
M_HWCE = [MRow_3;MRow_5;MRow_7;]
Maximum = max(M_HWCE) %this is how far i got. T_D is the 9x17 array.
% Not sure how I would code it but I want to display the absolute maximum out of these three and also display the location that coincides with it
% I know how to write the display function in general, just not sure how to make matlab call out which location the maximum will coincide with

Answers (1)

Tommy
Tommy on 5 Apr 2020
This gives the maximum value among rows 3, 5, and 7, as well as the row and column of that value within T_d:
maximum = max(max(T_d([3 5 7],:),[],2));
[row, col] = find(T_d == maximum);

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!