Outputing a correspond element of another variable
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Cutie
am 30 Dez. 2020
Kommentiert: Ameer Hamza
am 30 Dez. 2020
I want my final output to be the element A that is equivalent to B(max)
A = ["Bayo" "Tun" "s"]
B = [21, 45, 11]
example
max(B) = 45
How do I output the corresponding element in A (in it original string format).
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 30 Dez. 2020
Bearbeitet: Ameer Hamza
am 30 Dez. 2020
Try this
A = ["Bayo" "Tun" "s"];
B = [21, 45, 11];
[~, idx] = max(B);
output = A(idx);
Result
>> output
output =
"Tun"
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!