Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 12488

Re: Modifying an external array within a loop

$
0
0

As for your more complex file.

 

Debugging a larger program is not really comfortable in Mathcad.

First you should use right-click, Trace Error to find the origin of the error.

Then the only aids are toggling Debug and using the commands "pause" and "trace", the latter you have already used as I see.

 

The error in your program is because in the very first iteration step most values in your n2.old are zero and you get a divison by zero at the calculation of "cond". I trapped that error using "on error" and set cond to 1000 to keep the iteration running.

 

The iteration will stop after 9 iterations, so k is 9 and the matrices Pp1, Pp2 and Ps will have 11 columns. In your return vector you used the column selector k+2 which throws an index out of range error. I changed it to k+1.

I have included some comments in red and added some trace stetements to help me in the debugging - feel free to delete them.

 

EDITED: Added some more comments


Viewing all articles
Browse latest Browse all 12488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>