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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by