How can i display variable name on message box?

조회 수: 3 (최근 30일)
yt man
yt man 2017년 2월 17일
댓글: Star Strider 2017년 2월 18일
The case is:
in workspace, there are some variable name and corresponding value
for example
name=value
A=1
B=2
C=3
D=4
How to display the minimum value included variable name in message box: A=1

채택된 답변

Star Strider
Star Strider 2017년 2월 17일
Try this:
A=1;
B=2;
C=3;
D=4;
varcell = {'A','B','C','D'};
varvctr = [A B C D];
[minvar,idx] = min(varvctr);
msg = sprintf('%s = %d',varcell{idx},varvctr(idx));
msgbox(msg, 'Minimum: ')
  댓글 수: 8
yt man
yt man 2017년 2월 18일
Thanks Walter, its work!!!
Star Strider
Star Strider 2017년 2월 18일
Thank you Walter!
Fast asleep here (UTC-7) during that exchange.

댓글을 달려면 로그인하십시오.

추가 답변 (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