The max matrix of two matrices

조회 수: 64 (최근 30일)
S. David
S. David 2014년 8월 7일
편집: Praveen Pawar 2018년 3월 6일
Hello,
If I have two N-by-N matrices A and B, how can I find the N-by-by matrix C such that its (m,n)th element is the max of the (m,n)th element in A and the (m,n)th element in B?
Note: I don't want to use a for loop because N is quiet large.
Thanks

채택된 답변

Kelly Kearney
Kelly Kearney 2014년 8월 7일
  댓글 수: 1
Ben11
Ben11 2014년 8월 7일
Nicely done I think I over-complicated this :)

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

추가 답변 (2개)

Ben11
Ben11 2014년 8월 7일
Try this:
C = arrayfun(@(x,y) max(x(:),y(:)),A,B)

Praveen Pawar
Praveen Pawar 2018년 3월 6일
편집: Praveen Pawar 2018년 3월 6일
If I have two vectors of dimension (X,1) and (Y,1). I want to compare (x1,y1), (x2,y2) and so on and store the larger number in another vector. How to do this?

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by