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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Return Variable

IRarch
7-Bedrock

Return Variable

Hello everyone,

 

Lets say I have:

x=2 and y=5

 

I want to create a new variable that is going to be equal to the variable with the highest value, per say...

 

z=max(x,y)

 

and in return get 'y' not 5

but if I change the 'x' and 'y' values I want it to return whichever variable has the highest value.

 

PS Im new at this, maybe I am missing a simple rule of programming, not sure... 

4 REPLIES 4
LucMeekes
23-Emerald III
(To:IRarch)

The short answer is: What you want is not possible with mathcad.

 

The longer answer is:

You can write a formula that will tell you which one is the larger of the two input values, but the result is not a 'variable' in the sense that (I think) you mean: The symbolic answer to a numerical comparison.

 

Hmm. I tried to demonstrate it was not possible, and found that it IS possible in Mathcad 11:

LM_20180127_Return variable.png

 But I have my doubts on the usefullness of this, and on whether it works in Mathcad 15 or Prime.

 

Succes!

Luc

RichardJ
19-Tanzanite
(To:LucMeekes)

It doesn't work in Mathcad 15, so I very much doubt it works in Prime.

 

 

Here is the result obtained in the MC15 M045 and MP 3.1 versions.

This is a great alternative, Thanks!
Top Tags