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

 Réponse acceptée

Kelly Kearney
Kelly Kearney le 7 Août 2014

3 votes

C = max(A,B);

1 commentaire

Ben11
Ben11 le 7 Août 2014
Nicely done I think I over-complicated this :)

Connectez-vous pour commenter.

Plus de réponses (1)

Ben11
Ben11 le 7 Août 2014

0 votes

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

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by