How can i display variable name on message box?

1 回表示 (過去 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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by