Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Dear All,
I have found a fault in MP, (else and else if) is not working properly! Please see attached file.
I think they stop working properly, when there is (+ or -) in the equation.
Enjoy the discovery
Solved! Go to Solution.
It's not an error in Prime but rather an error in using it.
In Mathcad, as in other programming languages, too, the result of boolean expressions are represented as numbers. 0 denotes FALSE and any other number would mean TRUE.
You write "if i=1 OR 2" which is equivalent to "if i=1 OR TRUE" . This condition is TRUE in every case (because the second part of the OR, the 2, is considered to be TRUE) and so the else if branch is never executed.
You would have to write "if i=1 OR i=2" to get what you want.
I don't see any reason for the augment function you use, simply using tr would do the same, even better if you place it after the for-loop and not inside.
See attached some ways to achieve what you want for the last example you posted.
My copy of Prime 2 won't open your document.
Alan
Hi,
Its in MP 3.0
You'll need someone with MP3 to look at it then (you might consider renaming the file!).
Alan
Use please tr[i<--if(...,...,...)
Work in Prime Express too!
Probably a syntax issue - issue replicated in MP2;
I think that because you have the IF as { if {i=0} or {2} } it is evaluating 2 as true & it always calculates the first block.
In the correct cases there are no differences to show the error.
Regards
Andy
It's not an error in Prime but rather an error in using it.
In Mathcad, as in other programming languages, too, the result of boolean expressions are represented as numbers. 0 denotes FALSE and any other number would mean TRUE.
You write "if i=1 OR 2" which is equivalent to "if i=1 OR TRUE" . This condition is TRUE in every case (because the second part of the OR, the 2, is considered to be TRUE) and so the else if branch is never executed.
You would have to write "if i=1 OR i=2" to get what you want.
I don't see any reason for the augment function you use, simply using tr would do the same, even better if you place it after the for-loop and not inside.
See attached some ways to achieve what you want for the last example you posted.