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

Mathcad Prime 3.0 "IF" "Else If" help

ptc-5373964
1-Visitor

Mathcad Prime 3.0 "IF" "Else If" help

See attached spreadsheet.

I am trying to set up a simple if-otherwise statement and I am running into some trouble.

1.) I am not sure if it even set up correctly

2.) I am getting an error reffering to scalar vs. matrix.

If Me< (or eqaul to) Myw use first equation. (0.92-.17*Me etc.)

If not, use the second one (1.92-1.17etc.)

Any help or input is greatly appreicatied.

Thank you,

jReck

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ptc-5373964)

1.) I am not sure if it even set up correctly

No, you didn't.

2.) I am getting an error reffering to scalar vs. matrix.

Because you tried to multiply the first expression with an if-construct.

See attached.

31.12.png

View solution in original post

6 REPLIES 6
Werner_E
25-Diamond I
(To:ptc-5373964)

1.) I am not sure if it even set up correctly

No, you didn't.

2.) I am getting an error reffering to scalar vs. matrix.

Because you tried to multiply the first expression with an if-construct.

See attached.

31.12.png

Better use not the operator but the function if.

We can use in this case the free Mathcad Express!

IfFunc.png

Happy New Year!

Thanks for the help guys!

How would you set up an "IF" statement with two "IFs"? See attached.

The middle equation should be the controlling factor.Mathcad+Question-LLB.jpg

Werner_E
25-Diamond I
(To:ptc-5373964)

I guess the second if should be under the first one, not inside and you should use "else if".

Looking at the examples of the built-in help would be a good idea.

See the first example here:

http://www.ptc.com/cs/help/mathcad_hc/prime3_hc/mprime/programming_strategies.html#styler-id1.1.1.8.6.1

The local variable y in that example has no relationship to the function-name y (but I consider it bad habit to use the same name for two different things). In fact you could use that example without any temporary variable at all (but using it is considered better style and is less failure prone with larger programs).

If you are interested in using your sheet with the free Prime Express Edition, as Valery pointed out, you may also use nested if-functions.

Werner Exinger wrote:

If you are interested in using your sheet with the free Prime Express Edition, as Valery pointed out, you may also use nested if-functions.

You can find on my site Mathcad sheets for Prime (if operator) and for Express (if function) - http://twt.mpei.ac.ru/TTHB/2/OIVT/IVTANThermo/Eng/index.htm

And for Russian Mathcad - Smath.

And for Excel too.

Announcements

Top Tags