Find one Max-value from 2 columns from matrix

조회 수: 4 (최근 30일)
Nik Rocky
Nik Rocky 2020년 6월 16일
댓글: Nik Rocky 2020년 6월 16일
Hello,
i have a matrix:
M =
3.0000 0.9873 3.0000 0
10.0000 0.1518 10.0000 0.1255
10.0000 0.1561 10.0000 0.1735
10.0000 0.1619 10.0000 0.2110
10.0000 0.0994 10.0000 0.4389
6.0000 0.1010 6.0000 0.3090
10.0000 0.1150 10.0000 0.2852
and want get one Max-Value from 2 and 4 column.
I tried:
out = max(M(:,2:2:4))
but I get two answers.
out = max(max(M(:,2:2:4)))
works, but is not nice, I think =)
Maybe there are better solution?

채택된 답변

madhan ravi
madhan ravi 2020년 6월 16일
편집: madhan ravi 2020년 6월 16일
out = max(reshape(M(:,2:2:4),1,[])
% >= 2018b
out = max(M(:,2:2:4), [], 'all')
  댓글 수: 1
Nik Rocky
Nik Rocky 2020년 6월 16일
out = max(reshape(M(:,2:2:4),1,[]))
works, thank you! =)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by