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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

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

SD_8739877
2-Explorer

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".

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:SD_8739877)

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
Werner_E
25-Diamond I
(To:SD_8739877)

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

 

Werner_E
25-Diamond I
(To:SD_8739877)

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?

Announcements

Top Tags