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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Loop Conversion from MathCAD15 to Prime9 Variable Issue

GregH
4-Participant

Loop Conversion from MathCAD15 to Prime9 Variable Issue

When I ran the conversion tool it converted mathcad15 statement

GregH_0-1711982895273.png

to Prime 9 Statement

 

GregH_1-1711982963850.png

which only works if a precede it with an additional variable definition 

GregH_2-1711983031175.png

where NPS1 is already defined.

Any ideas why this additional variable statement is required for Prime9 but not Mathcad15?

 

 

GregH
1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:GregH)

What you are trying to do is equivalent to:

LucMeekes_0-1711992211298.png

At the time of creation of the vector, it's element values are unknown.

I guess Prime was built as an even more lazy machine than Mathcad, although, in Mathcad this doesn't work either:

LucMeekes_1-1711992364374.png

 

Success!
Luc

View solution in original post

4 REPLIES 4
LucMeekes
23-Emerald III
(To:GregH)

What you are trying to do is equivalent to:

LucMeekes_0-1711992211298.png

At the time of creation of the vector, it's element values are unknown.

I guess Prime was built as an even more lazy machine than Mathcad, although, in Mathcad this doesn't work either:

LucMeekes_1-1711992364374.png

 

Success!
Luc

GregH
4-Participant
(To:LucMeekes)

Hello Luc, thanks for the review and explanation. It makes sense to me that the vector creation was the issue. They must of handled it differently in MC15 with the if/otherwise statement. When Prime 9 did the conversion it changed this throughout the program to the new if/else format.

 

GregH_0-1712020727870.png

 

GregH
JKT
12-Amethyst
12-Amethyst
(To:GregH)

If I recall correctly, Mathcad 15 first checks the condition and then calculates the appropriate fork. The other fork is not handled at all and thus the error didn't happen. Prime checks both forks and sees the error.

Werner_E
24-Ruby V
(To:JKT)


@JKT wrote:

...

Prime checks both forks and sees the error.


Correct! On contrary to Mathcad, Prime does not use short-circuit evaluation (-> Short-circuit evaluation - Wikipedia).
Neither for boolean expressions nor for if-statements.

 

Here are two different ways to create the desired vector (I assume n to be a range running from 0 to N).

Werner_E_0-1712153189577.png

Even though the second approach is much shorter I would prefer the first one for better clarity and 'cause it does not need a range n to be defined (its replaced by the explicit internal for-loop). This for-loop allows the very same if-statement to work without an error on contrary to the usage of the range variable n (which is kind of an implicit loop).

 

 

Top Tags