Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hello,
I am using a for loop to combine two small matrices. The intent is that if both values exceed 0.2, then the values at an index are to be added together. If either or both of the two values is less than or equal to 0.2, then only the greater of the two values is kept. For some reason, no matter what the index values are the condition where it takes the maximum always triggers.
However, when I tried putting parentheses around the boolean statement (just throwing stuff at the wall), the second operation would always trigger.
I don't understand where I'm going wrong here, I am not proficient with programming in Mathcad.
Solved! Go to Solution.
You have to write if (DC.V[i <=0.2) v (DC.T[i <=0.2)
The parenthesizes are optional, "<=" has priority over "v". This is also the reason why your condition always triggers.
What you wrote is interpreted as if (DC.V]i) v (DC.t]i <= 0.2) and because any non-zero value is interpreted as TRUE and in your case all DC.V.i are non.-zero, the combined condition is always true.
EDIT: You may replace your OR condition by if min (DC.V[i, DC.T[i) >= 0.2 and exchange the if- and else branch if you like.
You have to write if (DC.V[i <=0.2) v (DC.T[i <=0.2)
The parenthesizes are optional, "<=" has priority over "v". This is also the reason why your condition always triggers.
What you wrote is interpreted as if (DC.V]i) v (DC.t]i <= 0.2) and because any non-zero value is interpreted as TRUE and in your case all DC.V.i are non.-zero, the combined condition is always true.
EDIT: You may replace your OR condition by if min (DC.V[i, DC.T[i) >= 0.2 and exchange the if- and else branch if you like.