Hello everyone,
I have had to convert a MathCAD spreadsheet from one of the old formats to Prime 2.0 and I am having trouble with program functionality. The spreadsheet is essentially a group of sub-programs or routines that are called on in a larger program further down in the sheet (pg. 37). At this point the program will not run due to a "These values cannot be compared" error. I have converted similar worksheets with essentially the same sub-programs and sub routines and not had this problem. The error appears to be the Evolve sub-program (Pg. 33) but it does not provide the source ofthe error.
Any explanation as to what is wrong and how to fix it would be appreciated.
Solved! Go to Solution.
OK, I gave it a last try and found the reason for the error but you will have to find out what causes Prime to give different results than Mathcad.
In the routine used to calculate xxx there is a loop which iterates the local variable t from 0 to 7200 (tmax/Delta_t). When t is 1483 the error is thrown because spybot gets complex and when Evolve() is called with that parameter, Evolves calls Er() with spybot as param and Er compares it with another variable for size which is not possible for complex numbers. I didn't bother to further investigate in finding out what causes spybot to take a complex value.
I changed the file by putting all above Evolve() in a collapsed area and deleted all after the calculation of xxx in the hope for a better performance (with not much success).
I turned the calculation of xxx in a function. The argument of that function (xxxfunc()) is the time value at which the calculation would stop (because a return is triggered) just before the call of Evolve() and return the values which would be fed into Evolve.
Its really a shame we don't have trace() anymore in Prime.
Don't be fooled by the document name. It is only considered a "Working Model" in MathCAD 15.
1. Please call functions after its creating:
f(x, y, z):=....
f(1, 2, 3)=
and see an answer or... an error message.
2. We can have in Mathcad Prime values with different dimentions in matrix:
Which functions do you see that are called prior to their creation? I cannot find any and the error is not that there is an undefined function or variable.
Also, I know that getting rid of the "removing dimensions" step would be much cleaner, but they did function in the old version and so I'd rather not remove that portion without exploring all of the options. It is so engrained in all of the subroutines and the final Program that I'm fairly sure that removing it at this point would make a huge mess. Unless you have any ideas on how to do this more simply?
It seems to be pointing me to this portion of the Evolve subroutine. It looks exactly the same as a spreadsheet that I converted previously (that functioned normally). I'm still not sure what exactly is wrong with this or how this is causing the error.
Sorry - the function round has 2 arguments.
Valery Ochkov wrote:
Sorry - the function round has 2 arguments.
You MAY use 2 arguments with round(), but you mustn't - the second argument defaults to zero. So the syntax in the shown code snippet is OK!
Valery, maybe you confused it with Round() (note the capital R) - here you need two arguments.
Is there anything else you can see there? Mathcad didn't actually highlight that portion of the code. When I tried error tracing it brought my cursor there though.
Amanda Rock wrote:
Is there anything else you can see there?
Unfortunately not. I looked at your sheet two or three times but had to give up every time as its really hard to follow and Prime would heavily slow down my machine, making scrolling and navigating in the sheet a matter of slow-motion. Lame machine and Prime is not really resource-friendly at all.
We lack the trace command for programs in Prime so we have no convenient way to get the values of the variables at a specific point before it fails. The only thing I could think of what could go wrong in the section you highlighted is that of a wrong index, but I guess you would get a more meaningful error message in that cases:
1) hdiv=0, division by zero
2) sdiv is not an integer (vector index must be an int)
3) Deltazbot>0 AND round(ls/hdiv)<sdiv+1; in that case the index would be neagtiv. Otherwise the index calculated in the if branch is always smaller than j and I think we can assume that spz[j already exists (the else branch would be faulty otherwise)
And then - these are all errors which would have already shown up in MC15.
So, regrettably, I have no clue.
P.S.: Prime 3 is just around the corner and was announced to be available at the end of summer. Maybe ....
OK, I gave it a last try and found the reason for the error but you will have to find out what causes Prime to give different results than Mathcad.
In the routine used to calculate xxx there is a loop which iterates the local variable t from 0 to 7200 (tmax/Delta_t). When t is 1483 the error is thrown because spybot gets complex and when Evolve() is called with that parameter, Evolves calls Er() with spybot as param and Er compares it with another variable for size which is not possible for complex numbers. I didn't bother to further investigate in finding out what causes spybot to take a complex value.
I changed the file by putting all above Evolve() in a collapsed area and deleted all after the calculation of xxx in the hope for a better performance (with not much success).
I turned the calculation of xxx in a function. The argument of that function (xxxfunc()) is the time value at which the calculation would stop (because a return is triggered) just before the call of Evolve() and return the values which would be fed into Evolve.
Its really a shame we don't have trace() anymore in Prime.
Well that's interesting! When I clicked on "Reply" I got a message saying "Please note, your reply will need to be approved by a moderator before it is posted in the forum."
Edit: OK. I just figured it out. It applies to everyone, on all forums. At the rate this post is moderated, solving someone's problem will now take weeks rather than hours (I posted last night at 10:30pm, it's now 3:20pm the next day, and still waiting....).
Still being moderated?