find min or max value element from more than two matrices
    17 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I know how we can find min or max value element from two matrices. For more than two matrices we can do two by two and then compare but I was wondering if there is any other simple way to find min or max value element from more than two matrices?
0 件のコメント
採用された回答
  George Papazafeiropoulos
      
 2014 年 6 月 2 日
        
      編集済み: George Papazafeiropoulos
      
 2014 年 6 月 2 日
  
      % data
matrix1=rand(2);
matrix2=rand(3);
matrix3=rand(4);
% engine
c=nan(4,4,3);
c(1:2,1:2,1)=matrix1;
c(1:3,1:3,2)=matrix2;
c(1:4,1:4,3)=matrix3;
% result
d=min(c,[],3)
e=max(c,[],3)
3 件のコメント
  Image Analyst
      
      
 2014 年 6 月 2 日
				Are you sure? It's not what you asked for. You didn't say that you wanted an array of maxes and an array of mins after the individual arrays were all lined up in the upper left corner. And the values will depend on where you align the smaller matrices over the larger matrices.
その他の回答 (1 件)
  Image Analyst
      
      
 2014 年 6 月 2 日
        For 3 matrices, you can do
minValue = min([a(:);b(:);c(:)])
maxValue = max([a(:);b(:);c(:)])
It's easy to see how to adapt it for more matrices.
2 件のコメント
  dpb
      
      
 2014 年 6 月 2 日
				
      編集済み: Image Analyst
      
      
 2014 年 6 月 2 日
  
			Good 'un to use (:) to avoid the dimensions problem...don't know why didn't think of it. I removed the sorrier response.
参考
カテゴリ
				Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




