How to vectorize max / min number in row

3 ビュー (過去 30 日間)
Ole
Ole 2020 年 2 月 14 日
コメント済み: Ole 2020 年 2 月 14 日
Ho to vectorize the min and max value on each row for a matrix
a = linspace(2,5,10); b = linspace(0,8,10);
A = [a' b']
2.000000000000000 0
2.333333333333333 0.888888888888889
2.666666666666667 1.777777777777778
3.000000000000000 2.666666666666667
3.333333333333333 3.555555555555555
3.666666666666667 4.444444444444445
4.000000000000000 5.333333333333333
4.333333333333334 6.222222222222222
4.666666666666666 7.111111111111111
5.000000000000000 8.000000000000000
the result should be
maxr = 2, 2.33, 2.66,3 , 3.55 ...
minr = 0, 0.88, 1.77. 2.66, 3.33 ...

採用された回答

Stephen23
Stephen23 2020 年 2 月 14 日
>> max(A,[],2)
ans =
2.0000
2.3333
2.6667
3.0000
3.5556
4.4444
5.3333
6.2222
7.1111
8.0000
>> min(A,[],2)
ans =
0.00000
0.88889
1.77778
2.66667
3.33333
3.66667
4.00000
4.33333
4.66667
5.00000
  1 件のコメント
Ole
Ole 2020 年 2 月 14 日
Thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by