How can i display variable name on message box?

3 visualizaciones (últimos 30 días)
yt man
yt man el 17 de Feb. de 2017
Comentada: Star Strider el 18 de Feb. de 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

Respuesta aceptada

Star Strider
Star Strider el 17 de Feb. de 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 comentarios
yt man
yt man el 18 de Feb. de 2017
Thanks Walter, its work!!!
Star Strider
Star Strider el 18 de Feb. de 2017
Thank you Walter!
Fast asleep here (UTC-7) during that exchange.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by