필터 지우기
필터 지우기

How to vectorize max / min number in row

조회 수: 2 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by