Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
First of all thank you for helping me. I am trying to figure out a way to use a if statement to compare to see if two variables are equal to each other?
Solved! Go to Solution.
You should first know that comparing for equality is to be used with caution.
Note that Mathcad is software that uses approximations for numerical values only. You should not be surprised if, when a is assigned the value 1/9 and b is assigned the value 1, then the comparison 9*a = b would render False { that is: 0, instead of 1 for True}.
Having said that, you can use an equals statement in an if statement:
if(a=b,3,4)
results in 3 if a=b, and 4 if a is unequal to b.
Taking account of numerical approximations, it is generally better to compare a to b with:
if(|a-b|<delta,3,4). And be sure to assign an appropriate positive value to delta beforehand.
Success!
Luc
Thank you these values are all input variables coming for an excel spreadsheet I just to trying to write a function I can call to determine which input variables are the same.
Does this work for MathCad 15 sorry forgot to mention that...
Yes, it works for Mathcad 15, 14, 13, 12, 11 and below.
Success!
Luc