cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

How to find the name of a variable in a set of data

SD_8739877
2-Guest

How to find the name of a variable in a set of data

How do I find the name of the variable that has the maximum value in a set of data. For example, if I have x=3, y=5 and z=2. I want to find the variable name for the maximum value. In this case it would be "y".

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Unfortunately Prime offers no way to access the NAMES of variables.

But if you collect all values in a vector, you cannot only find the maximum value but also the positions, the indices where in the vector this value occurs. Notice that by default the first element has the index 0.

Werner_E_0-1676491859617.png

 

View solution in original post

4 REPLIES 4

Unfortunately Prime offers no way to access the NAMES of variables.

But if you collect all values in a vector, you cannot only find the maximum value but also the positions, the indices where in the vector this value occurs. Notice that by default the first element has the index 0.

Werner_E_0-1676491859617.png

 

Thank you for your response! I was able to take what you said one step further. I am not worried about repeating numbers. I am just trying show the maximum moment on a beam with different load cases. 

 

SD_8739877_0-1676504897705.png

 

You could also use the lookup() function to do the job.

But nonetheless it is still necessary to define a separate vector with the "names".

Werner_E_0-1676522107844.png

 

This question does not appear to be well formulated. One reason that many of us use Mathcad is that it is "unit aware", How should it compare variables with different SI types unless, as Werner hints, you first collect all your variables into groups of common types and the look for the maximum of each type.

 

But then, how do you compare these maximums?

Top Tags