Outputing a correspond element of another variable

1 visualización (últimos 30 días)
Cutie
Cutie el 30 de Dic. de 2020
Comentada: Ameer Hamza el 30 de Dic. de 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).

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 30 de Dic. de 2020
Editada: Ameer Hamza el 30 de Dic. de 2020
Try this
A = ["Bayo" "Tun" "s"];
B = [21, 45, 11];
[~, idx] = max(B);
output = A(idx);
Result
>> output
output =
"Tun"
  4 comentarios
Cutie
Cutie el 30 de Dic. de 2020
Thank you so much!
Ameer Hamza
Ameer Hamza el 30 de Dic. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by