Clear Filters
Clear Filters

Outputing a correspond element of another variable

1 view (last 30 days)
I want my final output to be the element A that is equivalent to B(max)
A = ["Bayo" "Tun" "s"]
B = [21, 45, 11]
max(B) = 45
How do I output the corresponding element in A (in it original string format).

Accepted Answer

Ameer Hamza
Ameer Hamza on 30 Dec 2020
Edited: Ameer Hamza on 30 Dec 2020
Try this
A = ["Bayo" "Tun" "s"];
B = [21, 45, 11];
[~, idx] = max(B);
output = A(idx);
>> output
output =

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!