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