Mostrar comentarios más antiguos
Hi,
I'm selecting the max of three different values
distmax=max([dist1 dist2 dist3])
which gives for example
distmax= 3.434
is there a possibility to have the name of the value instead of the value itself, like
distmax = dist1
thank you
Respuesta aceptada
Más respuestas (1)
Jan
el 20 de Jun. de 2011
It is possible to get the name:
a = rand;
b = rand;
c = rand;
function Name = GetMaxName(a, b, c)
[Value, Index] = max([a, b, c]);
Name = inputname(Index);
But Wlater's solution is much more stable and reliable, because INPUTNAME replies an empty string for temporary objects, e.g. in "GetMaxName(round(a) ...)". Using the name of a variable as information is a fragil programming method.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!