Skip to main content
5-Regular Member
March 6, 2025
Solved

Passing equation array function into Matrix

  • March 6, 2025
  • 3 replies
  • 2503 views

hi @LucMeekes 

 

I am passing array of equations into an Array

JK_9391805_0-1741263839804.png

And then want to get this function in the form of matrix like below wherein A is the Matrix, which I want to pass to reference calculation worksheet, which is called within main worksheet.

JK_9391805_4-1741264145698.png

It gives the error to check label.

Can anyone help me to understand and solve this.

I could do this in Mathcad 15 and now struggling in Prime.

 

Regards,

JK_9391805

 

 

Best answer by Werner_E

You are right that the behaviour of evaluating combined Boolean expression unfortunately has changed in Prime.

 

Mathcad used "short-circuit evaluation". This means that when three Boolean expressions are combined with OR, the first one is checked and if the result is "true" the others are not evaluated anymore because its clear that the whole expression must be "true".

 

Prime evaluates every single boolean and decides afterward about the result.

As you already noticed, the error occurs when the limit is a string because its not allowed to compare a string  with a numeric value.

 

So given that this is the expression which throws the error

Werner_E_0-1741523442283.png

on way to avoid the error is to split it

Werner_E_1-1741523482723.png

another is to wrap the last Boolean expression which could throw the error in a try and catch

Werner_E_2-1741523523043.png

Guess the first way is better readable.

EDIT: It just came to my mind that there may be a problem with both suggestions if "min_limit" is a string but neither "-" nor "NA".
The first workaround would throw an error in this case which is the same behaviour as MC15 would show

The second suggestion would return "true" in this case. Change the "1" to "0" and it always will return "false" in this case.

 

Of course you would also have to apply similar changes for the other combined Booleans wherever this error could be thrown as well.

 

See here for a thorough explanation of short-circuit evaluation and also some pros and cons of using it. It does not help as there is no way to turn this feature on in Prime but the article may give a hint why PTC might have decided against using short-circuit eval (in case they really did this on purpose).

Short-circuit evaluation - Wikipedia

3 replies

25-Diamond I
March 6, 2025

Please attach your sheet. How should we see how the variables are actually labelled just from a picture?

We also don't see how you defined your ArrayOfEqns and the functions used therein.

If something worked in Mathcad (15), that doesn't mean it will work in Prime - unfortunately.

It may help if you also post a Mathcad 15 worksheet demonstrating that what you did worked in that version.

General advice: Global assignments should be used very sparely and with great care. Whenever possible (and its possible most of the time) avoid using them.

23-Emerald V
March 6, 2025

As Werner says, Mathcad Global Definitions should be used with great care, especially in Mathcad Prime which is not as permissive as the prior Mathsoft Mathcad.

 

However, Iโ€™d guess that your problem arises because youโ€™re trying to define PassFunction with Global Definition whilst you define SymbFun using a standard Definition.

 

Mathcad looks at Global Definitions before standard Definitions.  Consequently, Mathcad will attempt to create PassFunction without knowing what SymbFun is.

 

Stuart

25-Diamond I
March 6, 2025

Well spotted, but then this would also not work in MC15 and fail with the very same error message.

5-Regular Member
March 7, 2025

Attached is the Prime file, 

25-Diamond I
March 7, 2025

And you really claim that doing so worked in Mathcad 15? It doesn't !!

 

Don't use global definitions and it works OK

Werner_E_0-1741342916237.png

 

And then, why not simply

Werner_E_1-1741343537129.png

 

or

 

Werner_E_2-1741344087418.png

?

 

Was there any specific reason for using the global assignments?

 

 

 

25-Diamond I
March 7, 2025

For completeness sake here to show that what you tried does not work in Mathcad 15 either

Werner_E_0-1741345041867.png