フィルターのクリア

The max matrix of two matrices

43 ビュー (過去 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 日
C = max(A,B);
  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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by