Matlab help with coding

1 回表示 (過去 30 日間)
ii
ii 2019 年 10 月 9 日
回答済み: Stephen Deaton 2019 年 10 月 10 日
What would be the code to compute the maximum value of column 1 that is less than 200?
The numbers are
1 5 600
2 5 155
8 5 234
3 5 100
  1 件のコメント
John D'Errico
John D'Errico 2019 年 10 月 10 日
What have you tried? If nothing why not? For example, a loop with a test inside would suffice. Or you could do better, by first using a vectorized test to identify all elements less than 200, and THEN using max. So why not show what you would try, as this is a quite basic question.

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

採用された回答

Stephen Deaton
Stephen Deaton 2019 年 10 月 10 日
A = [1 5 600
2 5 155
8 5 234
3 5 100];
maxval = max(A(A(:,1)<200,1))
If you want to change which column you search for, then change the 1's to the corresponding column number (e.g. maxval_col3 = max(A(A(:,3)<200,3))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by