Show older comments
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
Accepted Answer
More Answers (1)
Jan
on 20 Jun 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.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!