The max matrix of two matrices

10 visualizaciones (últimos 30 días)
S. David
S. David el 7 de Ag. de 2014
Comentada: Ben11 el 7 de Ag. de 2014
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

Respuesta aceptada

Kelly Kearney
Kelly Kearney el 7 de Ag. de 2014
C = max(A,B);
  1 comentario
Ben11
Ben11 el 7 de Ag. de 2014
Nicely done I think I over-complicated this :)

Iniciar sesión para comentar.

Más respuestas (1)

Ben11
Ben11 el 7 de Ag. de 2014
Try this:
C = arrayfun(@(x,y) max(x(:),y(:)),A,B)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by