MATLAB Projects DISCUSSION

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

Started by syedzainnasir How can I find each max element of three matrices as new matrix?
2 replies 248 views 2 participants
Latest activity · 06 Mar 2017

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

syedzainnasir MATLAB Projects Forum
#1
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] a = [2, 5; 6, 9]; b = [3, 3; 8, 1]; c = [5, 5; 2, 7];[/code] How can I get the new matrix max with each max element in all three matrices?
[code]max = [5, 5; 8, 9][/code] 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?

Community replies 2

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

#2
That's not much difficult, use the below code: [code]maxMatrix = [max(a) max(b) max(c)];[/code] 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.

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

#3
[quote=theenggprojects post_id=553 time=1489047921 user_id=2] That's not much difficult, use the below code: [code]maxMatrix = [max(a) max(b) max(c)];[/code] 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. [/quote] Thanks for the code :)
TEP COMMUNITY