How to create an alphabetical matrix?

Given:
D = [12 3 56 78 3 4 5 10 91 21]
E = [16 81 18 3 5 7 9 12 9 11]
F = [6 7 68 24 13 2 8 16 22 2]
I need to write a Matlab code that creates a new alphabetical matrix that displays the letter of the matrix that has the HIGHEST value of the 3 matrices D, E, F from above on an element by element basis.
I know that the new matrix should be:
OutputMatrix = [E E F D F E E F D D]
However, I am unsure how to arrive at that output using Matlab. Is this possible? Any help appreciated. Thanks in advance.

 Accepted Answer

7 Comments

Thanks so much, that's definitely very helpful. However, I am not sure that it will solve my problem though, because I have 3 matrices, rather than 2?
Could you elaborate?
You can do two max() calls, and use two masks, one comparing against the first variable, one against the second, and the third is ~(first | second)
Joey Smith
Joey Smith on 5 Oct 2017
Edited: Joey Smith on 5 Oct 2017
Do you mind giving a brief example of this? I have not used mask feature before, so I am struggling to follow exactly what you mean. If not, that's okay. You've been more than enough help and I can't thank you enough! :-)
"[...] I have 3 matrices, rather than 2" Hint:
>> [m,ix] = max([D(1),E(1),F(1)])
m =
16
ix =
2
mask is not a feature, it is just a variable name.
m = max( max(A, B), C );
mask1 = m == A
mask2 = m == B
mask3 = m == C
I think I got it now. You are a very patient man. Thank you! :-)

Sign in to comment.

More Answers (1)

Categories

Community Treasure Hunt

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

Start Hunting!