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

Return Variable

Regular Member

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

Re: Return Variable

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

Re: Return Variable

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

 

 

Re: Return Variable

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

Re: Return Variable

This is a great alternative, Thanks!
Announcements