Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to find the marker in the biggest row?

1 回表示 (過去 30 日間)
Danielle Garcia
Danielle Garcia 2018 年 12 月 6 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Im doing a project where I get the following marker locations [5 2; 7 3; 4 5; 6 5; 8 6; 3 8]
I am trying to use the maxx command to find the marker that is in the biggest row. However when i use the max command it is giving me the value for the max row and column. If anyone knows how to code to get the marker that is just in the highest row not column thatd be great.
  1 件のコメント
Image Analyst
Image Analyst 2018 年 12 月 7 日
What is meant by the biggest row, and what is meant by the highest row? Is the biggest row the row with the highest index number (i.e., the last/bottom row, which is 6 for your example)? Or is it the row with the biggest sum? Is the highest row the top one, i.e., row #1?

回答 (2 件)

Mark Sherstan
Mark Sherstan 2018 年 12 月 7 日
If you run the following code youll get the following answer:
A = [5 2; 7 3; 4 5; 6 5; 8 6; 3 8];
[maxNum maxIdx] = max(A)
%%%%%%%%%%%%%%%%%%%%%%%%
maxNum =
8 8
maxIdx =
5 6
The variable maxIdx indicates the row where the max values are located for each column. If you run an additional max function you can find where the largest row is located, in your case it is 6.
max(maxIdx)
ans =
6

madhan ravi
madhan ravi 2018 年 12 月 7 日
a=[5 2; 7 3; 4 5; 6 5; 8 6; 3 8]
[~,Location]=max(sum(a,2));
a(Location,:) %returns largest row

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by