## How can I find each max element of three matrices as new matrix?

You can post your problem related to MATLAB Projects here. We will try our best to help you out.
Charles
Posts: 20
Joined: Sat Feb 18, 2017 7:12 am

### How can I find each max element of three matrices as new matrix?

Maybe the question is a little bit confused, I'll make an example below.

Let's say I have a 3 matrices a, b, c with same size.

Code: Select all

``````a = [2, 5; 6, 9];
b = [3, 3; 8, 1];
c = [5, 5; 2, 7];``````
How can I get the new matrix max with each max element in all three matrices?

Code: Select all

``max = [5, 5; 8, 9]``
I know I could create logical matrix like a>b and then do the math, calc it out, is there any other more efficient way to do it?

theenggprojects
Posts: 25
Joined: Tue Feb 07, 2017 12:51 pm

### Re: How can I find each max element of three matrices as new matrix?

That's not much difficult, use the below code:

Code: Select all

``maxMatrix = [max(a) max(b) max(c)];``
maxMatrix will be your matrix with maximum values of matrix a, b and c. Moreover, it will be a vector and if you want a 2 Dimensional matrix then add d too.

Charles
Posts: 20
Joined: Sat Feb 18, 2017 7:12 am

### Re: How can I find each max element of three matrices as new matrix?

theenggprojects wrote:
Thu Mar 09, 2017 8:25 am
That's not much difficult, use the below code:

Code: Select all

``maxMatrix = [max(a) max(b) max(c)];``
maxMatrix will be your matrix with maximum values of matrix a, b and c. Moreover, it will be a vector and if you want a 2 Dimensional matrix then add d too.
Thanks for the code 