Outputing a correspond element of another variable

1 回表示 (過去 30 日間)
Cutie
Cutie 2020 年 12 月 30 日
コメント済み: Ameer Hamza 2020 年 12 月 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 件のコメント
Cutie
Cutie 2020 年 12 月 30 日
Thank you so much!
Ameer Hamza
Ameer Hamza 2020 年 12 月 30 日
I am glad to be of help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by