Azzera filtri
Azzera filtri

Outputing a correspond element of another variable

1 visualizzazione (ultimi 30 giorni)
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).

Risposta accettata

Ameer Hamza
Ameer Hamza il 30 Dic 2020
Modificato: Ameer Hamza il 30 Dic 2020
Try this
A = ["Bayo" "Tun" "s"];
B = [21, 45, 11];
[~, idx] = max(B);
output = A(idx);
>> output
output =
  4 Commenti

Accedi per commentare.

Più risposte (0)


Community Treasure Hunt

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

Start Hunting!

Translated by