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

 Akzeptierte Antwort

Kelly Kearney
Kelly Kearney am 7 Aug. 2014

3 Stimmen

C = max(A,B);

1 Kommentar

Ben11
Ben11 am 7 Aug. 2014
Nicely done I think I over-complicated this :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Ben11
Ben11 am 7 Aug. 2014

0 Stimmen

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

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by