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일

1 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

ii
2019년 10월 9일

답변:

2019년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by