How to return only one of multiple identical max/min values?
    조회 수: 12 (최근 30일)
  
       이전 댓글 표시
    
I have multiple series, and in each one I want to find the maximum or minimum value and store it into a variable so at the end I have a matrix of maximums and a matrix of minimums. The problem is that some of the series appear to have more than one maximum (or minimum) and the program gives me an error message. How do I make Matlab return only the first of these values?
댓글 수: 1
  Siranjeevi Gurumani
 2021년 9월 17일
				Assuming A = matrix of more than one dimensions
and you want max of whole matrix 
A = [1,6,6;4,5,6];
max(max(A))
or
max(A,[],'all')
채택된 답변
추가 답변 (2개)
  Sean de Wolski
      
      
 2015년 7월 7일
        This is what the max and min function both do. Can you provide a minimal working example of what you have, what you want, and what you're doing now?
댓글 수: 2
  Sean de Wolski
      
      
 2015년 7월 7일
				mx = max([-5, -6, -8, -7, 1, 6, 6, 5, -3, -4, -6, -9])
I think you're over-thinking it :)
  Siranjeevi Gurumani
 2021년 9월 17일
        Assuming A = matrix of more than one dimensions
and you want max of whole matrix 
A = [1,6,6;4,5,6];
max(max(A))
or
max(A,[],'all')
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



