How can i display variable name on message box?
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!