# The max matrix of two matrices

**URL:** <https://discourse.julialang.org/t/the-max-matrix-of-two-matrices/56841>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 10, 2021, 1:06am UTC](https://discourse.julialang.org/t/the-max-matrix-of-two-matrices/56841 "2021-03-10T01:06:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oko/32/22734_2.png) [@Oko](https://discourse.julialang.org/u/Oko)\
**Post date:** [March 10, 2021, 1:06am UTC](https://discourse.julialang.org/t/the-max-matrix-of-two-matrices/56841/1 "2021-03-10T01:06:45Z")

</div>

If I have two N-by-N matrices A and B, how can I find the N-by-N 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? What would be the simplest way to get the output equivalent to the MATLAB max(A,B) command?

---

<div class="post-metadata">

**Author:** ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)\
**Post date:** [March 10, 2021, 1:08am UTC](https://discourse.julialang.org/t/the-max-matrix-of-two-matrices/56841/2 "2021-03-10T01:08:05Z")

</div>

Maybe try broadcasting? E.g. `max.(A, B)`

---

<div class="post-metadata">

**Author:** ![Oko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oko/32/22734_2.png) [@Oko](https://discourse.julialang.org/u/Oko)\
**Post date:** [March 10, 2021, 1:27am UTC](https://discourse.julialang.org/t/the-max-matrix-of-two-matrices/56841/3 "2021-03-10T01:27:18Z")

</div>

> [@dilumaluthge](#):
>
> `max.(A, B)`

Of course 🙂 I am stupid. Thanks for a quick handle.
