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일

3 개 추천

C = max(A,B);

댓글 수: 1

Ben11
Ben11 2014년 8월 7일
Nicely done I think I over-complicated this :)

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

추가 답변 (1개)

Ben11
Ben11 2014년 8월 7일

0 개 추천

Try this:
C = arrayfun(@(x,y) max(x(:),y(:)),A,B)

태그

질문:

2014년 8월 7일

댓글:

2014년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by