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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

I have an old Mathcad file (14) I convert it to Prime 9 but the code does not work. Please help

KG_10853734
2-Explorer

I have an old Mathcad file (14) I convert it to Prime 9 but the code does not work. Please help

I have an old Mathcad file (14) I convert it to Prime 9 but the code does not work. Please help

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:KG_10853734)

There are many differences between Mathcad and Prime and in most cases Primes is not an improvement.

 

Prime does not allow for shortcut evaluation of branches which is the reason why the creation of the vector depsj fails.

Prime tries to evaluate the else branch even when q=qalt is true (the very first time) and so tries to access depsj which at that time still does not exist.

You may call it bad programming style to rely on shortcut evaluations, but it sure is convenient 😉

 

Solution is to define a vector depsj right in front of that program. I did it by assigning a dummy value like NaN for the first vector element and so creating a 1x1 vector. The value itself does not matter as it will be immediately overwritten by the correct  6x1 vector anyway.

Werner_E_0-1699645807681.png

The plots at the end use a title label which is not supported by Primes native plots. You will have to use a manually placed text region as a substitute. Furthermore Primes plots do not offer the option to add grid lines. Workarounds to create grids as part of the plots where posted here in the forum now and then.
Or you recreate the plots with the chart component. It supports amongst other features labels and grid lines, but unfortunately has its own serious disadvantages, too.But you may give it a try.

 

Mathcad:

Werner_E_1-1699646145438.png

Prime:

Werner_E_2-1699646183257.png

 

View solution in original post

2 REPLIES 2

KG_10853734_0-1699645316761.png

here it says depsj is not defined and it seems to be the problem

Werner_E
25-Diamond I
(To:KG_10853734)

There are many differences between Mathcad and Prime and in most cases Primes is not an improvement.

 

Prime does not allow for shortcut evaluation of branches which is the reason why the creation of the vector depsj fails.

Prime tries to evaluate the else branch even when q=qalt is true (the very first time) and so tries to access depsj which at that time still does not exist.

You may call it bad programming style to rely on shortcut evaluations, but it sure is convenient 😉

 

Solution is to define a vector depsj right in front of that program. I did it by assigning a dummy value like NaN for the first vector element and so creating a 1x1 vector. The value itself does not matter as it will be immediately overwritten by the correct  6x1 vector anyway.

Werner_E_0-1699645807681.png

The plots at the end use a title label which is not supported by Primes native plots. You will have to use a manually placed text region as a substitute. Furthermore Primes plots do not offer the option to add grid lines. Workarounds to create grids as part of the plots where posted here in the forum now and then.
Or you recreate the plots with the chart component. It supports amongst other features labels and grid lines, but unfortunately has its own serious disadvantages, too.But you may give it a try.

 

Mathcad:

Werner_E_1-1699646145438.png

Prime:

Werner_E_2-1699646183257.png

 

Announcements

Top Tags