How can i display variable name on message box?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
yt man
am 17 Feb. 2017
Kommentiert: Star Strider
am 18 Feb. 2017
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 Kommentare
Akzeptierte Antwort
Star Strider
am 17 Feb. 2017
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!