フィルターのクリア

Finding the maximum value in a specific row of a matrix

20 ビュー (過去 30 日間)
Meghan Brownlee
Meghan Brownlee 2015 年 11 月 18 日
回答済み: gowtham balu 2021 年 11 月 25 日
I have this matrix:
M = [3 6 1 -2; 3 0 -2 -4; 8 -3 5 4; -2 -3 -2 5];
And I need to find the maximum value in row 4, and next I need to know the maximum value in columns 2 and 3. I know it seems simple but I can't remember and the help command is not being very helpful. Thanks!
  2 件のコメント
Muhammad Affan Arif
Muhammad Affan Arif 2021 年 3 月 2 日
Although it's too late, might be helpful for others.
row_max = max(M'); %finds the maximum value in each row by taking transpose of matrix M
my_max_val = col_max(1,4) % gives the maximum value in row 4.
%For the maximum value in columns 2 and 3:
col_max = max(M);
col_max1 = col_max(1,2)
col_max2 = col_max(1,3)
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 3 月 2 日
編集済み: KALYAN ACHARJYA 2021 年 3 月 2 日
:) 2015 --2021

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

回答 (2 件)

KSSV
KSSV 2021 年 3 月 2 日
M = [3 6 1 -2; 3 0 -2 -4; 8 -3 5 4; -2 -3 -2 5];
[val1,idx1] = max(M(4,:)) % maximum in the row 4
[val2,idx2] = max(M(:,3)) % maximum in the column 3

gowtham balu
gowtham balu 2021 年 11 月 25 日
how to know the max value in row2,column4

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by