Outputing a correspond element of another variable

1 次查看(过去 30 天)
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).

采纳的回答

Ameer Hamza
Ameer Hamza 2020-12-30
编辑:Ameer Hamza 2020-12-30
Try this
A = ["Bayo" "Tun" "s"];
B = [21, 45, 11];
[~, idx] = max(B);
output = A(idx);
Result
>> output
output =
"Tun"
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by